Examples Submit Transaction Variable Price Product Purchase
February 14, 2023 at 10:38 AMSome products may require the user enter the amount to pay, these are products known as variable price products.
These products reflect the product minPrice
and maxPrice
in the Product properties and always return an input called
amount
in the list of required inputs.
Firstly must get all products inputs required to make the refill.
query ($id: ID!) {
node(id: $id) {
... on Product {
isPIN
inputs {
name
type
required
label
html {
type
maxlength
minlength
min
max
pattern
}
}
}
}
}
{
"id": "RWa1ZUVkVK21=="
}
{
"data": {
"node": {
"isPIN": false,
"inputs": [
{
"name": "amount",
"type": "float",
"required": true,
"label": "Amount",
"html": {
"type": "number",
"maxlength": null,
"minlength": null,
"min": 1,
"max": 100,
"pattern": null
}
},
{
"name": "accountNumber",
"type": "phone",
"required": true,
"label": "Phone Number",
"html": {
"type": "tel",
"maxlength": null,
"minlength": null,
"min": null,
"max": null,
"pattern": null
}
}
]
}
}
}
Then submit the transaction with all user inputs
mutation ($input: SubmitTransactionInput!) {
transactions {
submit(input: $input) {
transaction {
date
status
grossTotal
adjustments {
name
total
}
total
response {
... on PinSaleResponse {
pin
}
message
}
}
}
}
}
{
"input": {
"product": "RWa1ZUVkVK21==",
"inputs": { "accountNumber" : "+12345678901", "amount": "20" }
}
}
{
"data": {
"transactions": {
"submit": {
"transaction": {
"date": "2020-12-16T13:40:01-05:00",
"status": "COMPLETED",
"grossTotal": 20,
"adjustments": [],
"total": 20,
"response": {
"message": "Your account has been successfully credited."
}
}
}
}
}
}
The response has more properties than shown here, this is a basic example, to see all possible properties look for the
SubmitTransactionPayload
type object in the explorer