Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Callback value #57

Open
Focuslinkstech opened this issue Sep 21, 2023 · 6 comments
Open

Callback value #57

Focuslinkstech opened this issue Sep 21, 2023 · 6 comments

Comments

@Focuslinkstech
Copy link

Is there a way to pass some value when initializing transactions and the same value will be return as callback values?

e.g

return [
‘invoice’ : ‘inv100837’
];

and the callback value will be like:

{
"Body": {
"stkCallback": {
"MerchantRequestID": "29115-34620561-1",
"CheckoutRequestID": "ws_CO_191220191020363925",
"ResultCode": 0,
"ResultDesc": "The service request is processed successfully.",
"CallbackMetadata": {
"Item": [{
"Name": "Amount",
"Value": 1.00
},
{
"Name": "MpesaReceiptNumber",
"Value": "NLJ7RT61SV"
},
{
"Name": "TransactionDate",
"Value": 20191219102115
},
{
"Name": "PhoneNumber",
"Value": 254708374149
}],

     return [
          “invoice”: “inv100837”
                 ]
     }        
  }    

}
}

the invoice number can be use to verify the transactions.

@shabran01
Copy link

Yes, you can pass a value when initializing a transaction and use that value to identify and verify the transaction in the callback response. In your example, you're using an "invoice" value to uniquely identify a transaction.

Here's how you can structure the transaction initiation and callback response to include the "invoice" value:

  1. Transaction Initiation:
    When initiating a transaction, you can include the "invoice" value in the request payload or parameters. For example:

{
"invoice": "inv100837",
// Other transaction-related information
}

1.Callback Response:
When the callback is triggered after the transaction is processed, you can include the "invoice" value in the callback response to link it to the original transaction:

json
Copy code
{
"Body": {
"stkCallback": {
"MerchantRequestID": "29115-34620561-1",
"CheckoutRequestID": "ws_CO_191220191020363925",
"ResultCode": 0,
"ResultDesc": "The service request is processed successfully.",
"CallbackMetadata": {
"Item": [
{
"Name": "Amount",
"Value": 1.00
},
{
"Name": "MpesaReceiptNumber",
"Value": "NLJ7RT61SV"
},
{
"Name": "TransactionDate",
"Value": 20191219102115
},
{
"Name": "PhoneNumber",
"Value": "254708374149"
},
{
"Name": "Invoice",
"Value": "inv100837" // Include the invoice value here
}
]
}
}
}
}
In the callback response, you've added an "Invoice" item in the "CallbackMetadata" section, which contains the "invoice" value associated with the transaction. You can use this value to verify and link the callback response to the original transaction based on the "invoice" number.

@Focuslinkstech
Copy link
Author

here is what i want to send to api using STKpush? the value did not return

$curl_Tranfer2_post_data = [
    'BusinessShortCode' => $Business_Code,
    'Password' => $password,
    'Timestamp' =>$Time_Stamp,
    'TransactionType' =>$Type_of_Transaction,
    'Amount' => $trx['price'],
    'PartyA' => $phone_number,
    'PartyB' => $Business_Code,
    'PhoneNumber' => $phone_number,
    'CallBackURL' => $CallBackURL,
    'AccountReference' => $config['CompanyName'],
    'TransactionDesc' => $trx['plan_name'],
	'Trxid' => $trx['id'],
	'AmountToPay' => $trx['price'],
    ];

@shabran01
Copy link

shabran01 commented Sep 24, 2023 via email

@Focuslinkstech
Copy link
Author

Yes, i have did that already, can the stkpush sent back the amontToPay and trxid value send to the api in stkpush because it doesn’t send it back?

@shabran01
Copy link

shabran01 commented Sep 24, 2023 via email

@shabran01
Copy link

shabran01 commented Sep 24, 2023 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants