You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// This is just for very basic implementation reference, in production, you should validate the incoming requests and implement your backend more securely.
* Example code for SnapBI, you can uncomment and run the code.
56
+
* To cancel transaction you can use externalId or referenceNo.
57
+
* The difference is based on the request body/ payload.
58
+
* you can refer to the variable $directDebitCancelByReferenceBody or $directDebitCancelByExternalIdBody (for direct debit) or $vaCancelBody (for va) to see the value.
59
+
*
60
+
* Below are example code to cancel the transaction.
61
+
*/
62
+
63
+
/**
64
+
* Example code for Direct Debit cancel using externalId
65
+
*/
66
+
67
+
/**
68
+
* Basic implementation of Direct Debit to cancel transaction
69
+
*/
70
+
$snapBiResponse = SnapBi::directDebit()
71
+
->withBody($directDebitCancelByExternalIdBody)
72
+
->cancel($external_id);
73
+
74
+
/**
75
+
* Example code of Direct Debit to cancel transaction using your existing access token
76
+
*/
77
+
$snapBiResponse = SnapBi::directDebit()
78
+
->withAccessToken("")
79
+
->withBody($directDebitCancelByExternalIdBody)
80
+
->cancel($external_id);
81
+
82
+
/**
83
+
* Example code of Direct Debit to cancel transaction by adding or overriding the accessTokenHeader and TranasctionHeader
84
+
*/
85
+
$snapBiResponse = SnapBi::directDebit()
86
+
->withBody($directDebitCancelByExternalIdBody)
87
+
->withAccessTokenHeader([
88
+
"CHANNEL-ID" => "12345"
89
+
])
90
+
->withTransactionHeader([
91
+
"CHANNEL-ID" => "12345"
92
+
])
93
+
->cancel($external_id);
94
+
95
+
/**
96
+
* Example code for Direct Debit to cancel using referenceNo
97
+
*/
98
+
99
+
/**
100
+
* Basic implementation of Direct Debit to cancel transaction
101
+
*/
102
+
$snapBiResponse = SnapBi::directDebit()
103
+
->withBody($directDebitCancelByReferenceBody)
104
+
->cancel($external_id);
105
+
106
+
/**
107
+
* Example code of Direct Debit to cancel transaction using your existing access token
108
+
*/
109
+
$snapBiResponse = SnapBi::directDebit()
110
+
->withAccessToken("")
111
+
->withBody($directDebitCancelByReferenceBody)
112
+
->cancel($external_id);
113
+
114
+
/**
115
+
* Example code of Direct Debit to cancel transaction by adding or overriding the accessTokenHeader and TransactionHeader
116
+
*/
117
+
$snapBiResponse = SnapBi::directDebit()
118
+
->withBody($directDebitCancelByReferenceBody)
119
+
->withAccessTokenHeader([
120
+
"CHANNEL-ID" => "12345"
121
+
])
122
+
->withTransactionHeader([
123
+
"CHANNEL-ID" => "12345"
124
+
])
125
+
->cancel($external_id);
126
+
127
+
/**
128
+
* Example code for VA (Bank Transfer) to cancel transaction
129
+
*/
130
+
131
+
/**
132
+
* Basic implementation of VA (Bank Transfer) to cancel transaction
133
+
*/
134
+
$snapBiResponse = SnapBi::va()
135
+
->withBody($vaCancelBody)
136
+
->cancel($external_id);
137
+
138
+
/**
139
+
* Example code of VA (Bank Transfer) to cancel transaction using your existing access token
140
+
*/
141
+
$snapBiResponse = SnapBi::va()
142
+
->withAccessToken("")
143
+
->withBody($vaCancelBody)
144
+
->cancel($external_id);
145
+
146
+
/**
147
+
* Example code of VA (Bank Transfer) to cancel transaction by adding or overriding the accessTokenHeader and TransactionHeader
148
+
*/
149
+
$snapBiResponse = SnapBi::va()
150
+
->withBody($vaCancelBody)
151
+
->withAccessTokenHeader([
152
+
"CHANNEL-ID" => "12345"
153
+
])
154
+
->withTransactionHeader([
155
+
"CHANNEL-ID" => "12345"
156
+
])
157
+
->cancel($external_id);
158
+
159
+
} catch (\Exception$e) {
160
+
echo$e->getMessage();
161
+
}
162
+
echo"snap bi response = " . print_r($snapBiResponse, true), PHP_EOL;
163
+
164
+
functiongenerateRandomNumber()
165
+
{
166
+
$prefix = "6280"; // Fixed prefix
167
+
$randomDigits = mt_rand(100000000, 999999999); // Generate 9 random digits
0 commit comments