Giter VIP home page Giter VIP logo

Comments (3)

multikitty avatar multikitty commented on August 11, 2024

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.

from sumup-ecom-php-sdk.

crownbackend avatar crownbackend commented on August 11, 2024

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: {▶} }

from sumup-ecom-php-sdk.

crownbackend avatar crownbackend commented on August 11, 2024

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

from sumup-ecom-php-sdk.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.