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

What should I do after getting the checkoutResponse??? #38

Open
shahadatjuton opened this issue Feb 22, 2023 · 3 comments
Open

What should I do after getting the checkoutResponse??? #38

shahadatjuton opened this issue Feb 22, 2023 · 3 comments

Comments

@shahadatjuton
Copy link

image

I am getting the checkoutResponse properly, now what should I do? How to evaluate final order status?

@multikitty
Copy link

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.

@crownbackend
Copy link

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](http://127.0.0.1:8000/_profiler/open?file=vendor/sumup/sumup-ecom-php-sdk/src/SumUp/Exceptions/SumUpResponseException.php&line=10#line10) {#885 ▼ #message: "Client error" #code: 400 #file: "[/home/belhassen/Documents/dev/ams/ams-mantes-association/vendor/sumup/sumup-ecom-php-sdk/src/SumUp/HttpClients/Response.php](http://127.0.0.1:8000/_profiler/open?file=vendor/sumup/sumup-ecom-php-sdk/src/SumUp/HttpClients/Response.php&line=103#line103)" #line: 103 trace: {▶} }

@crownbackend
Copy link

Do you have any idea why I get a 400 error every time?

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

3 participants