Open shahadatjuton opened 1 year ago
After calling create function, you should call pay function. You can implement this by 2 ways. First is to create a checkout page using sumup-card widget (https://gateway.sumup.com/gateway/ecom/card/v2/sdk.js)
var sumupcard = SumUpCard.mount({
checkoutId: checkoutId,
showAmount: true,
showFooter: true,
onResponse: function(type, body) {
console.log("Type", type);
console.log("Body", body);
if (type == "success") {
...
} else {
...
}
},
});
You can check the status of payment (e.g. "PAID" or "FAILED") in the body of response.
Second is to call process checkout API using customService of sumup-ecom-php-sdk like the following.
$customService = $sumup->getCustomService();
$response = $customService->request("PUT", "/v0.1/checkouts/:id", [
"payment_type": "card",
"card": {
"name": "John Doe",
"number": "4242424242424242",
"expiry_month": "12",
"expiry_year": "34",
"cvv": "123"
}
]);
I hope this will help you.
how can I test with a fake card? because when I do a put to validate the checkout it returns me a "client error" this is my code ` try { $data = json_encode([ 'payment_type' => 'card', 'card' => [ 'name' => 'John Doe', 'number' => '4242424242424242', 'expiry_month' => '12', 'expiry_year' => '34', 'cvv' => '123', ], ]);
$sumup = new SumUp([
'app_id' => $this->clientId,
'app_secret' => $this->clientSecert,
'grant_type' => 'client_credentials',
'scopes' => ['payments', 'transactions.history', 'user.app-settings', 'user.profile_readonly'],
]);
$customService = $sumup->getCustomService();
$checkoutId = 'id';
$response = $customService->request('PUT', "/v0.1/checkouts/{$checkoutId}", $data);
dump($response);
} catch (SumUpSDKException $exception) {
dd($exception);
}`
`SumUp\Exceptions\SumUpResponseException {#885 ▼
trace: {▶} }`
Do you have any idea why I get a 400 error every time?
I am getting the checkoutResponse properly, now what should I do? How to evaluate final order status?