Pi Payments and Pi SDK & Sandbox | Pi Workshop | Pi Network Payments

Pi Payments a bitBay (PIB) open source software which is a lightweight and open source multi-chain platform for payment systems. It can be used to create and manage smart contracts for decentralized applications. It is suitable for creating and managing payment systems and is developed in a way to support many blockchains with different programming languages including Java, .NET, Python, JavaScript and Go. PIB is a tool for creating and managing payment systems and is developed in a way to support many blockchains with different programming languages including Java, .NET, Python, JavaScript and Go. PIB can be used for running smart contracts, Multi-signature (M-S) escrow, escrow service, crowdfunding and many other features.

Pi Payments is a platform that provides a secure and easy to use payment gateway. Pi SDK & Sandbox is an integrated toolkit for developers to build their own Pi enabled applications. Pi Network Payments is a payment gateway for your Pi Network. It is a complete and easy to use payment gateway for your Pi network.

Payment using Pis and Pi SDK & Sandbox | Pi Workshop | Pi Network Payments 9

Welcome to another Hackathon Workshop video :). This week our Core Team developer Hakkyung will show you how to utilize Pi Payments and Pi SDK & Sandbox when building your app. Tap the videos on the home screen above to learn more about how to #Buildpi2gether!

Building using the Raspberry Pi SDK

Developers may use the Pi SDK to create apps that work with the Pi money and Pi Platform. To install and utilize the Pi SDK, follow the instructions.

Pi Payment

We’re introducing the Pi App Engine today for developers who wish to use Pi Core Team’s scalable server infrastructure to create and distribute Pi applications, particularly Ecosystem apps. Check out our Hackathon workshop films, where two Core Team members will teach you how to use the Developer Portal and Pi App Engine, by tapping the Read More icon on the home screen.

Pi Payments and Pi SDK & Sandbox | Pi Workshop | Pi Network PaymentsPi Brainstorm | Pi Brainstorm Kya Hai | What is Pi Brainstorm?

The goal of this app is to include all Pioneers in the development of the Pi ecosystem. The app aims to channel the creativity, collective knowledge, skills, and support of our huge community of over 10 million active Pioneers into real-world apps, utilities, and ecosystem development, all of which are critical to Pi’s success. Brainstorming with Pi


Add the following script tags to any sites where the Pi Apps SDK is needed:

The following keys are accepted by the config object provided to the init function:

  • version (string, needed) – this is necessary to guarantee that your program is compatible with subsequent SDK versions that may include breaking changes (in which case breaking changes will be implemented under a higher version number)
  • sandbox: (boolean, optional) – allows you to execute the SDK in a sandbox.

In sandbox mode, use the SDK:

If you’ve established a development URL in the developer portal, you may now execute your app in the sandbox environment (https://sandbox.minepi.com). To setup this and see your Sandbox URL, go to the developer portal by visiting develop.pi in the Pi Browser.

Typically, if you’re using a framework or a boilerplate that supports it, you should be able to set up your sandbox flag to match your development environment. For example, most good Node boilerplates will set up the value of process.env.NODE_ENV to either “development” or “production”, and you could do something like: Pi.init({ version: “2.0”, sandbox: <%= process.env.NODE_ENV !== ‘production’ %> }). This depends on your setup, but running the Pi SDK in sandbox mode will generally happen whenever your app is running in development.


Promise: Pi.authenticate(scopes: Array, onIncompletePaymentFound: Function, onIncompletePaymentFound: Function)

Value returned:

type AuthResult = accessToken: string, user: uid: string, username: string, type AuthResult = type AuthResult = type AuthResult = type AuthResult = type AuthResult = type AuthResult = type AuthResult = type AuthResult = type AuthResult =


Usernames and payments are among the scopes that are available.

Currently unimplemented

Currently, all calls to the authenticate method are assumed to have requested all scopes — that is, all calls are treated as if the first parameter was [‘username’, ‘payments’]. When calling authenticate, however, you should only add the scopes that your app requires. Prior to the public release of the Pi platform, scopes support will be implemented.

The following is a list of the different keys accessible on the AuthResult[‘user’] object, as well as the scopes that must be present for those keys to be present:

Field Description Scope Requirement
uid The user’s app-local identification. This is unique to this person and this application. If the user revokes the rights they gave to your app, it will alter. (none)
username The Pi username of the user. username


Signature: (payment: PaymentDTO) => void

When a user is authorized and tries to start a new payment flow, the SDK checks to see whether the user has any outstanding payments. In this context, an unfinished payment is one that has been sent to the Pi blockchain but still has status.developer completed set to false (i.e. the developer has not called the /complete endpoint on this payment).

This callback will be called using the payment’s PaymentDTO if an incomplete payment is discovered.

It is your duty to fulfill the appropriate payment when this callback is triggered (you should most likely send the payment DTO to your server, and process it according to your business logic). You’ll need to accomplish this before you can ask the user for a fresh payment.


To make a new payment, follow these steps:

type PaymentData = { amount: number, memo: string, metadata: Object, }; type PaymentCallbacks = { onReadyForServerApproval: (paymentId: string) => void, onReadyForServerCompletion: (paymentId: string, txid: string) => void, onCancel: (paymentId: string) => void, onError: (error: Error, payment?: PaymentDTO) => void, }; Pi.createPayment(paymentData: PaymentData, callbacks: PaymentCallbacks): void;

The paymentData and callbacks arguments are sent to the createPayment method.

It will instantly begin the payment flow, which will appear on top of your app, allowing the user to evaluate the payment and either submit or reject the blockchain transaction.

Payments are being made at the same time.

If there is an open payment with your app for the current user while making a new payment:

  • The open payment will be revoked if the user has not yet completed the blockchain transaction.
  • The new payment will be denied (onError will be called) if the user has already completed the blockchain transaction, and the onIncompletePaymentFound callback that was provided to the authenticate function will be triggered with the current payment (use this callback to resolve the situation, e.g by sending the previous payment to your server for server-side completion).

paymentData keys:


This is the amount the user will be charged by your app.

Example: 3.1415.


For this payment, a note is required. The user will see this on the payment confirmation page. Use this to describe what the user is paying for in a few words.

Digital cat #1234, for example.


This payment may have any Javascript object attached to it. This is for your personal use only. This object should be used to connect this payment to your own business logic.

OrderId: 1234, itemIds: [11, 42, 314] as an example

callbacks keys:


Signature: (paymentId: string) => void

When the payment identification (paymentId) is received from Pi Servers, this is called.

Send the paymentId to your backend for Server-Side Approval using this callback. On the dedicated Payments page, you can learn more about Server-Side Approval and the whole payment procedure.


Signature: (paymentId: string, txid: string) => void

When the user has submitted the transaction to the Pi blockchain, this is called.

Send the blockchain transaction identification (txid) and paymentId to your backend for Server-Side Completion using this callback. On the dedicated Payments page, you can learn more about Server-Side Completion and the whole payment procedure.


Signature: (paymentId: string) => void

When a payment is canceled, this is referred to as (by a user action, or programmatically).

The payment may be canceled because the user refused it directly or because of another blocking situation: the user does not have sufficient money on their account to complete the payment, another payment has been made simultaneously…


Signature: (error: Error, payment?: PaymentDTO) => void

This is what it’s called when there’s a problem with the payment and it can’t be completed. The second parameter will be available if the payment has been made, and you may utilize it to analyze the problem. Only the first argument will be supplied otherwise.

Type PaymentDTO

The parameters provided to onIncompletePaymentFound and onError are of this kind.

PaymentDTO = identifier: string, type PaymentDTO = identifier: string, type PaymentDTO = identifier: string, type PaymentDTO = identifier: / The user uid: string payment identification / The quantity of the user’s app-specific ID: number, / Payment amount memo: string, $$$$$$$$$$$$$$$$ / The following is a string supplied by the developer and shown to the user metadata: Object, to address: string, to address: string, to address: string, to address: string, to address: string, to address / The blockchain transaction’s recipient address created at: string, / The time when the payment was made. / The following are the status flags that reflect the current condition of this payment status: developer approved: boolean, / Server-Side Approval transaction verified: boolean, / Blockchain transaction verified developer completed: boolean, / Server-Side Completion cancelled: boolean, / Cancelled by the developer or by Pi Network user cancelled: boolean, / Cancelled by the user string, txid: / The transaction’s id on the blockchain verified: boolean, / True if the transaction matches the payment, false else _link: string, / A link to the operation on the Blockchain API,

Participate in the conversation

To open a native share dialog, do the following:

openShareDialog(title: string, message: string): void; Pi.openShareDialog(title: string, message: string): void;

This technique will launch a native Share dialog (supplied by the phone’s operating system), allowing your users to share material from your app with their peers.

The JS SDK is a frontend SDK that can be used in HTML pages and Single-Page Apps that are delivered in the Pi Browser.

You must declare your applications on the Developer Portal in order for the SDK to work properly (open develop.pi in the Pi Browser to access the Developer Portal).

This SDK isn’t intended for NodeJS apps that run on the server.


Add the following script tags to any sites where the Pi Apps SDK is needed:

The Pi Network JS SDK will be loaded as a global window as a result of this. Pi object.


Verify a user’s identity.

You can’t do anything with the user until you’ve properly authenticated them (such reading their information or requesting a payment from them). They will be prompted with a dialog asking for their permission to share their data with your app for the first time.

/ Verify the user’s identity and get authorization to request money from them: [‘payments’] const scopes = / ; In the SDK documentation, you may learn more about this callback: /*… */ function onIncompletePaymentFound(payment) authenticate.pi (scopes, onIncompletePaymentFound). then(function(auth) console.log(Hi there! You’re ready to pay! );). if(function(error) console.error(error); if(function(error) console.error(error); if(function(error) console.error(error); if

Make a payment request

The createPayment function allows you to request a payment to your app’s account from the current user.

The Pi Wallet will provide the user with a modal that allows them to sign the transaction and send it to the Pi blockchain.

Pi.createPayment( / Amount to be paid: amount: 3.14, / Amount to be paid: amount: 3.14, / Amount to be paid: amount: 3.14, / Amount to be paid: amount: 3.14 The user will be given an explanation of the payment: “…”, for example, “Digital kitten #1234”, / An arbitrary metadata object supplied by the developer – for your own use: metadata: /*… */, / for example: kittenId: 1234, / You’ll need to implement callbacks, which you can learn more about in the full documentation linked below: onReadyForServerApproval: function(paymentId) /*… */, onReadyForServerCompletion: function(paymentId, txid) /*… */, onCancel: function(paymentId) /*… */, onError: function(error, payment) /*… */, onError: function(error, payment) /*… */,);

This code block is a simplified version to show you how it works.

The payment must go through a Server-Side Approval flow and a Server-Side Completion flow to ensure that all parties involved (your app, your server, the Pi servers, and the Pi blockchain) are in sync.

Please refer to the following:

Demonstration Pi App

You may use the Pi Browser to check out the sample Pi App. Simply enter demo.pi into the Pi Browser’s address box.

Related Tags

This article broadly covered the following related topics:

  • stripe api
  • stripe api docs
  • stripe subscription
  • stripe payment methods
  • stripe subscription api