Skip to content

Commit 9bc0d05

Browse files
committed
Paynow docs
1 parent 13966c6 commit 9bc0d05

File tree

1 file changed

+87
-1
lines changed

1 file changed

+87
-1
lines changed

docs/developers/modules/paynow.mdx

Lines changed: 87 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,58 @@ import { Callout } from 'nextra-theme-docs'
55

66
## Overview
77

8+
The Pay Now module allows Lunar Client users to complete purchases directly within the game, providing a faster, more seamless checkout experience.
89

10+
**Overlay Mode**
11+
12+
This mode displays the Pay Now checkout flow as an overlay on the Minecraft window, similar to opening an inventory. It provides the most seamless experience and is the preferred method. Overlay mode is only available on **Windows**.
13+
14+
**Window Mode**
15+
16+
As a fallback, and for **macOS** and **Linux** users, a separate window opens to display the Pay Now checkout flow. While not as seamless as overlay mode, this ensures compatibility across all operating systems.
17+
18+
## Usage Guidelines
19+
20+
To ensure a smooth user experience, servers must only open checkout windows from user-initiated actions. Examples include, but aren't limited to:
21+
22+
**Allowed (User-Initiated Actions):**
23+
- Clicking a link in chat
24+
- Running a command
25+
- Clicking a button in a GUI
26+
27+
**Not Allowed (Automated/Intrusive Actions):**
28+
- Triggering on login
29+
- Automatically opening at set intervals (e.g., every 30 minutes)
30+
- Automatically opening during flash sales, events, or other promotions without user interaction
31+
32+
This feature is designed to enhance the user experience by providing a seamless checkout process, misuse of this module, such as creating a disruptive or intrusive purchase flow, will result in restricted access in the future.
33+
34+
## Integration
35+
36+
The only piece of information sent from the server to the client to trigger a checkout window is the **PayNow checkout token**. This unique identifier represents an in-progress checkout.
37+
38+
If a player is not using Lunar Client, the same PayNow checkout can be used on the web at: `https://checkout.paynow.gg/?t=<token>`
39+
40+
**Example flow**
41+
1. Create a checkout token using the PayNow API that includes the desired products in the basket.
42+
2. If the player is using Lunar Client: Send an Apollo packet to open the checkout modal.
43+
3. If the player is not using Lunar Client: Send a chat message with a PayNow payment link.
44+
45+
**PayNow API**
46+
47+
Checkout tokens are created via the [PayNow Checkout API](https://docs.paynow.gg/management/management-api/checkout). This API allows programmatic checkout creation and more.
48+
49+
**Getting started with the PayNow API**
50+
51+
🔗 [Documentation](https://docs.paynow.gg/getting-started/overview)<br/>
52+
53+
**API Authentication**
54+
55+
You’ll need your **API Key** from: [PayNow API Keys](https://guides.paynow.gg/integration/api-keys)
56+
57+
<Callout type="warning" emoji="⚠️">
58+
Never share these credentials with Lunar Client or external servers. They should only be used while communicating with PayNow.
59+
</Callout>
960

1061
### Sample Code
1162
Explore each integration by cycling through each tab to find the best fit for your requirements and needs.
@@ -17,7 +68,30 @@ Explore each integration by cycling through each tab to find the best fit for yo
1768
**Display Pay Now Embedded Checkout**
1869

1970
```java
20-
71+
public void displayPayNowEmbeddedCheckoutExample(Player viewer, String checkoutToken) {
72+
Optional<ApolloPlayer> apolloPlayerOpt = Apollo.getPlayerManager().getPlayer(viewer.getUniqueId());
73+
74+
if (!apolloPlayerOpt.isPresent()) {
75+
viewer.sendMessage("Complete your purchase at https://checkout.paynow.gg/?t=" + checkoutToken);
76+
return;
77+
}
78+
79+
ApolloPlayer apolloPlayer = apolloPlayerOpt.get();
80+
PayNowEmbeddedCheckoutSupport embeddedCheckoutSupport = apolloPlayer.getPayNowEmbeddedCheckoutSupport();
81+
82+
if (embeddedCheckoutSupport == PayNowEmbeddedCheckoutSupport.UNSUPPORTED) {
83+
viewer.sendMessage("Complete your purchase at https://checkout.paynow.gg/?t=" + checkoutToken);
84+
return;
85+
}
86+
87+
this.payNowModule.displayPayNowEmbeddedCheckout(apolloPlayer, checkoutToken);
88+
89+
if (embeddedCheckoutSupport == PayNowEmbeddedCheckoutSupport.OVERLAY) {
90+
viewer.sendMessage("Opening checkout as game overlay!");
91+
} else {
92+
viewer.sendMessage("Opening checkout in an external window!");
93+
}
94+
}
2195
```
2296

2397
</Tab>
@@ -31,7 +105,13 @@ Explore each integration by cycling through each tab to find the best fit for yo
31105
</Callout>
32106

33107
```java
108+
public void displayPayNowEmbeddedCheckoutExample(Player viewer, String checkoutToken) {
109+
OpenPayNowEmbeddedCheckoutMessage message = OpenPayNowEmbeddedCheckoutMessage.newBuilder()
110+
.setCheckoutToken(checkoutToken)
111+
.build();
34112

113+
ProtobufPacketUtil.sendPacket(viewer, message);
114+
}
35115
```
36116

37117
</Tab>
@@ -41,7 +121,13 @@ Explore each integration by cycling through each tab to find the best fit for yo
41121
**Display Pay Now Embedded Checkout**
42122

43123
```java
124+
public void displayPayNowEmbeddedCheckoutExample(Player viewer, String checkoutToken) {
125+
JsonObject message = new JsonObject();
126+
message.addProperty("@type", "type.googleapis.com/lunarclient.apollo.paynow.v1.OpenPayNowEmbeddedCheckoutMessage");
127+
message.addProperty("checkout_token", checkoutToken);
44128

129+
JsonPacketUtil.sendPacket(viewer, message);
130+
}
45131
```
46132

47133
</Tab>

0 commit comments

Comments
 (0)