GoodDocs
Search…
G$ Payments
G$ wallet works using payment links. Any vendor can create a simple payment request link that can be used on its website to start the payment process
G$ wallet works using payment links. Any vendor can create a simple payment request link that can be used on its website to start the payment process.

Payment Flow

  • User press on payment link on vendor website
  • GoodDollar wallet is opened with a confirmation screen showing payment details
  • Once user confirms, wallet sends transaction details via callback url defined by the vendor
  • vendor website upon receiving response via callback closes the wallet window and continues the checkout flow
The payment link has the form of:
https://wallet.gooddollar.org/?code=<safebase64encodedparams>
The code parameter is a base64 encoded object with the following fields
1
Code: {
2
m: string, //MNID encoded wallet address to receive payment
3
a: number, //amount of payment
4
r: string, //reason for payment
5
cat: Catergoy,//payment category
6
ven: Vendor //object vendor details,
7
}
8
9
Category: Enum {
10
DigitalServices = 1
11
SocialMedia = 2
12
Product = 3
13
Course = 4
14
Donation = 5
15
Other = 6
16
}
17
18
Vendor: {
19
cbu: url //callback url
20
ind: string //invoice id
21
web: url //vendor website
22
ven: string //vendor name
23
d: string //extra data for transferAndCall
24
}
25
Copied!
Example:
1
const params = {
2
m:'3dMkyEZ1QFLwi2aoUNkfV6B8Xe5s5eFw2nd',
3
a: 25.3,
4
r: 'The Commonists Manifesto',
5
cat: 3,
6
ven: {
7
cbu: 'https://bookstore.xyz/backend/paymentcall',
8
ind: '1234-urg',
9
web: 'https://bookstore.xyz',
10
ven: 'The Commons',
11
d:'this can be read from the ERC677 Transfer event',
12
}
13
}
Copied!
next to encode it you can run the following javascript code
1
encodeURIComponent(btoa(JSON.stringify(params)))
Copied!
The final payment link would be: https://wallet.gooddollar.org/?code=eyJtIjoiM2RNa3lFWjFRRkx3aTJhb1VOa2ZWNkI4WGU1czVlRncybmQiLCJhIjoyNS4zLCJyIjoiVGhlIENvbW1vbmlzdHMgTWFuaWZlc3RvIiwiY2F0IjozLCJ2ZW4iOnsiY2J1IjoiaHR0cHM6Ly9ib29rc3RvcmUueHl6L2JhY2tlbmQvcGF5bWVudGNhbGwiLCJpbmQiOiIxMjM0LXVyZyIsIndlYiI6Imh0dHBzOi8vYm9va3N0b3JlLnh5eiIsInZlbiI6IlRoZSBDb21tb25zIiwiZCI6InRoaXMgY2FuIGJlIHJlYWQgZnJvbSB0aGUgRVJDNjc3IFRyYW5zZmVyIGV2ZW50In19

Handling Callback Response From Wallet

The wallet will send a POST request to the callback url defined in the ven.cbu field.
Make sure your endpoint handles POST requests
The POST request send a JSON object with
  • invoiceId: specified by the vendor in ven.ind field
  • transactionId: the transaction hash of the payment on the Fuse blockchain
1
{ invoiceId: '123-udg', transactionId: '0x3593.....0374' }
Copied!

Verifying The Payment On The Fuse Blockchain

It is recommended to verify that the transactionId reported by the wallet in did happened and that it matches the payment details.
use any web3 library to read the events from the transaction.
The contract event ABI is: (See Smart Contracts to get the G$ token contract address)
1
["Transfer(indexed address from,indexed address to,uint256 value,bytes data)"]
Copied!
The last data field will contain the data supplied in the extra data field, if that field is omitted or empty then it will contain the data supplied in the invoice id field. This way you can verify that the transaction matches the specific payment.
Verify that the fields to, value and data match what you expect for the payment to prevent fraud
Last modified 1mo ago