Payment API
| Endpoint | Method | Description |
|---|---|---|
| /api/v0/rpc/payment.createStripeCheckoutSession | jsonRpc | Create stripe checkout session |
| payment:validateAppStore | websocket | Validate App Store payment receipt |
| payment:getBraintreeClientToken | websocket | Get client token for Braintree payment provider |
| payment:processBraintreePayment | websocket | Process Braintree payment |
| payment:cancelBraintreeSubscription | websocket | Cancel Braintree subscription |
| payment:getBraintreeSubscriptions | websocket | Get Braintree active subscriptions |
| payment:createStripeCheckoutSession | websocket | Create Stripe checkout session |
Create stripe checkout session
Method: jsonRpc
HTTP Method: POST
Path: /api/v0/rpc/payment.createStripeCheckoutSession
Description: Server creates checkout session and returns url to a Stripe-hosted payment page. Ref: https://stripe.com/docs/payments/checkout/how-checkout-works
Headers:
X-Session-Id: sessionToken
X-Network-Id: networkId
Request:
{
"product": string // name of the product to process
"amount": float // in case of balance top up, custom amount of dollars
"successUrl": string // redirect url on success, domain + path
"cancelUrl": string // redirect url on cancel, domain + path
}
Response:
{
"data": {
"url": string
}
"error": { "status": bool, "code": int, "message": string }
}
Validate App Store payment receipt
Method: websocket
Endpoint: payment:validateAppStore
Request:
{
"data": {
"receipt": string
}
"event": { "id": string, "date": timestamp }
}
Response:
{
"data": {
"valid": bool
}
"error": { "status": bool, "code": int, "message": string }
}
Get client token for Braintree payment provider
Method: websocket
Endpoint: payment:getBraintreeClientToken
Description: Client should request client token from Valuverse API server and then initiate Braintree sdk using that client token. Ref : https://developers.braintreepayments.com/start/hello-client/javascript/v2#get-a-client-token
Request:
{ empty }
Response:
{
"data": {
"token": string
}
"error": { "status": bool, "code": int, "message": string }
}
Process Braintree payment
Method: websocket
Endpoint: payment:processBraintreePayment
Description: After sending payment information to Braintree server, client get response with "payment method nonce" which need to be submitted to Valuverse API server. Ref: https://developers.braintreepayments.com/start/hello-client/javascript/v2#send-payment-method-nonce-to-server
Product could be one of the actions (with buying type) fetched from balance:getTokenAction endpoint.
Also, product could be buying_increase_balance in order to replenish balance by custom amount of money.
Request:
{
"data": {
"paymentNonce": string // payment nonce from Braintree server
"product": string // name of the product to process
"amount": float // amount of dollars to process
}
"event": { "id": string, "date": timestamp }
}
Response:
{
"data": {
"status": string // response status one of success / terminated / failed
}
"error": { "status": bool, "code": int, "message": string }
}
Cancel Braintree subscription
Method: websocket
Endpoint: payment:cancelBraintreeSubscription
Request:
{
"data": {
"product": string
}
"event": { "id": string, "date": timestamp }
}
Response:
{
"data": {
"status": string // response status one of success / terminated / failed
}
"error": { "status": bool, "code": int, "message": string }
}
Get Braintree active subscriptions
Method: websocket
Endpoint: payment:getBraintreeSubscriptions
Request:
{ empty }
Response:
{
"data": {
"subscriptions": [{
"planId": string
}]
}
"error": { "status": bool, "code": int, "message": string }
}
Create Stripe checkout session
Method: websocket
Endpoint: payment:createStripeCheckoutSession
Description: Server creates checkout session and returns url to a Stripe-hosted payment page. Ref: https://stripe.com/docs/payments/checkout/how-checkout-works
Request:
{
"data": {
"product": string // name of the product to process
"amount": float // in case of balance top up, custom amount of dollars
"successUrl": string // redirect url on success, domain + path
"cancelUrl": string // redirect url on cancel, domain + path
}
"event": { "id": string, "date": timestamp }
}
Response:
{
"data": {
"url": string
}
"error": { "status": bool, "code": int, "message": string }
}