Skip to content

Commit 10f013d

Browse files
committed
January 2023 doc updates
1 parent 387117e commit 10f013d

4 files changed

Lines changed: 21 additions & 5 deletions

File tree

SDK_reference.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ to be present:
7979
8080
Signature: `(payment: PaymentDTO) => void`
8181
82-
Every time the user is authenticated, and when they try to start a new payment flow, the SDK checks that there is no
82+
Every time when the user is authenticated, and when they try to start a new payment flow, the SDK checks that there is no
8383
incomplete payment for this user. An incomplete payment, in this context, is a payment which has been submitted to
8484
the Pi blockchain, but where `status.developer_completed` is still `false` (i.e. the developer has not called the
8585
`/complete` endpoint on this payment).
@@ -157,7 +157,8 @@ Example: `{ orderId: 1234, itemIds: [11, 42, 314] }`
157157

158158
Signature: `(paymentId: string) => void`
159159

160-
This is called when the payment identifier (paymentId) is obtained from Pi Servers.
160+
This is called when the payment identifier (paymentId) is obtained from Pi Servers. During the approval time period, this callback will be invoked multiple times in case of failure.
161+
If the initial trial fails, the Pi SDK will continue to invoke the function roughly every 10 seconds until the approval timer ends.
161162

162163
Use this callback to send the paymentId to your backend for **Server-Side Approval**.
163164
Read more about Server-Side Approval and the full payment flow in the dedicated
@@ -167,7 +168,8 @@ Read more about Server-Side Approval and the full payment flow in the dedicated
167168

168169
Signature: `(paymentId: string, txid: string) => void`
169170

170-
This is called when the user has submitted the transaction to the Pi blockchain.
171+
This is called when the user has submitted the transaction to the Pi blockchain. During the completion time period, this callback will be invoked multiple times in case of failure.
172+
If the initial trial fails, the Pi SDK will continue to invoke the function roughly every 10 seconds until the completion timer ends.
171173

172174
Use this callback to send the blockchain transaction identifier (txid), along with the paymentId
173175
to your backend for **Server-Side Completion**.

developer_portal.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,12 @@ With the help of Pi SDK and Pi API, you can create applications that run within
2424

2525
> When the app is connecting to the Pi Mainnet, you can pair one of your testnet apps to the mainnet app. More specific usage is coming soon in the future.
2626
27-
> When you're hosting the app on your server, you will also need to provide the url. Notice that you'll be asked to verify the ownership of the url after you register the app. After you filled in the required fields, you can submit to register your app by clicking on `Submit` button at the bottom of the page.
28-
2927
<div style="text-align:center;">
3028
<img src="./img/dev_portal_new_3.png" alt="drawing" width="200"/>
3129
</div>
3230

31+
> When you're hosting the app on your server, you will also need to provide the url. Notice that you'll be asked to verify the ownership of the url after you register the app. After you filled in the required fields, you can submit to register your app by clicking on `Submit` button at the bottom of the page.
32+
3333
3. After you register your app, you can see your apps in the main page. If you selected the paired app for your mainnet app, it will show like the following.
3434

3535
<div style="text-align:center;">

img/payment_flow_simplified.png

40.2 KB
Loading

payments.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,3 +64,17 @@ This implementation is your responsibility.
6464
> have made a payment. If the API call for Server-Side completion
6565
> returns a non-200 error code, **do not** mark the payment as complete on your
6666
> side, and **do not** deliver whatever the user was trying to buy.
67+
68+
69+
## Simplified flow
70+
71+
This diagram shows the same payment flow from your app's point of view in a simplified manner.
72+
73+
![Payment flow](./img/payment_flow_simplified.png)
74+
75+
1. Use the Pi SDK function to initiate the payment
76+
2. A callback function that gets called automatically by the Pi SDK (letting your App Server know that it needs to make an approve API request)
77+
3. An API request from your App Server to the Pi Server to approve the payment (letting the Pi Server know that you are aware of this payment)
78+
4. The Pi browser shows the payment detail page to a user, and we are waiting until the user signs the transaction
79+
5. A callback function that gets called automatically by the Pi SDK (letting your App Server know that it needs to make an complete API request)
80+
6. An API request from your App Server to the Pi Server to complete the payment (letting the Pi Server know that you completed this payment)

0 commit comments

Comments
 (0)