Giter VIP home page Giter VIP logo

sumup-ecom-php-sdk's Introduction

SumUp Ecommerce PHP SDK

Overview

This repository contains the open source PHP SDK that allows you to integrate quickly with the SumUp's API endpoints.

Installation

The SumUp eCom PHP SDK can be installed with Composer. Run the following command:

composer require sumup/sumup-ecom-php-sdk

Basic usage

try {
    $sumup = new \SumUp\SumUp([
        'app_id'     => 'YOUR-CLIENT-ID',
        'app_secret' => 'YOUR-CLIENT-SECRET',
        'code'       => 'YOUR-AUTHORIZATION-CODE'
    ]);
    $checkoutService = $sumup->getCheckoutService();
    $checkoutResponse = $checkoutService->create($amount, $currency, $checkoutRef, $payToEmail);
    $checkoutId = $checkoutResponse->getBody()->id;
//  pass the $chekoutId to the front-end to be processed
} catch (\SumUp\Exceptions\SumUpAuthenticationException $e) {
    echo 'Authentication error: ' . $e->getMessage();
} catch (\SumUp\Exceptions\SumUpResponseException $e) {
    echo 'Response error: ' . $e->getMessage();
} catch(\SumUp\Exceptions\SumUpSDKException $e) {
    echo 'SumUp SDK error: ' . $e->getMessage();
}

API Reference

For a full list of classes, see the API reference page.

FAQ

Roadmap

Version Status PHP Version
1.x Latest >= 5.6

License

For information about the license see the license file.

Contact us

If you have found a bug or you lack some functionality please open an issue. If you have other issues when integrating with SumUp's API you can send an email to [email protected].

sumup-ecom-php-sdk's People

Contributors

avoitovych avatar joelrose avatar lyubomir-sumup avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

sumup-ecom-php-sdk's Issues

$returnURL sometimes called twice by SumUp

I use the following to perform a checkout on my site:

        try {
            $sumup = $this->sumUpInstance();
            $checkoutService = $sumup->getCheckoutService();
            $checkoutResponse = $checkoutService->create($amount, $currency, $checkoutRef, $payToEmail, $description, $payFromEmail, $returnURL);
            $checkoutId = $checkoutResponse->getBody()->id;
            //  pass the $chekoutId to the front-end to be processed
        } catch (\SumUp\Exceptions\SumUpAuthenticationException $e) {
            echo 'Authentication error: ' . $e->getMessage();
        } catch (\SumUp\Exceptions\SumUpResponseException $e) {
            echo 'Response error: ' . $e->getMessage();
        } catch (\SumUp\Exceptions\SumUpSDKException $e) {
            echo 'SumUp SDK error: ' . $e->getMessage();
        }

When the provided $returnURL is accessed, the booking is marked as "Paid" and a confirmation email is sent.

However, it seems that sometimes SumUp will access this URL twice, at basically the same time, resulting in the customer receiving two confirmation emails (despite a check on if it's already been marked as paid).

Is this an issue on SumUp's side that is causing this duplicate callback to the $returnURL?

Fatal error: Class 'SumUp\SumUp' not found in

I get this error msg
Fatal error: Class 'SumUp\SumUp' not found in XXXX/XXXX/sumup-test.php on line 3
when I call this code as explained. sumup installed via composer

code
try { $sumup = new \SumUp\SumUp([ 'app_id' => 'YOUR-CLIENT-ID', 'app_secret' => 'YOUR-CLIENT-SECRET', 'code' => 'YOUR-AUTHORIZATION-CODE' ]); $checkoutService = $sumup->getCheckoutService(); $checkoutResponse = $checkoutService->create($amount, $currency, $checkoutRef, $payToEmail); $checkoutId = $checkoutResponse->getBody()->id; // pass the $chekoutId to the front-end to be processed } catch (\SumUp\Exceptions\SumUpAuthenticationException $e) { echo 'Authentication error: ' . $e->getMessage(); } catch (\SumUp\Exceptions\SumUpResponseException $e) { echo 'Response error: ' . $e->getMessage(); } catch(\SumUp\Exceptions\SumUpSDKException $e) { echo 'SumUp SDK error: ' . $e->getMessage(); }

Missing support of create checkout with merchant_code

Hello,
According to the SDK documentation (https://developer.sumup.com/docs/php-sdk/), the checkout needs creating with :

$checkoutResponse = $checkoutService->create($amount, $currency, $checkoutRef, $payToEmail);

However, according to the rest API, using the payToEmail field is discouraged and the mandatory merchant_code field should be used instead when creating checkouts: see https://developer.sumup.com/rest-api/#tag/Checkouts/paths/~1checkouts/post

pay_to_email | string <email>  Email address of the registered user (merchant) to whom the payment is made. It is highly recommended to use merchant_code instead of pay_to_email.

Looking at the SDK source code, there's no way to use merchant_code. See https://github.com/sumup/sumup-ecom-php-sdk/blob/master/src/SumUp/Services/Checkouts.php

public function create($amount, $currency, $checkoutRef, $payToEmail, $description = '', $payFromEmail = null, $returnURL = null)
    {

How bad is it to use payToEmail? Shouldn't the sdk evolve to take into account the API specifications?
Thanks!

Response error: request_not_allowed. Error 403 on Payment

Hi

I am trying to use the payments widget in a test environment initially but am having a 403 error when trying to create a checkout. I have previously had an email indicating that the payment scope was active when I was using the woocommerce interface.

My code is

try{
    $sumup = new \SumUp\SumUp([
        'app_id'     => get_option('cws_sumup_key'),
        'app_secret' => get_option('cws_sumup_secret_key'),
        'grant_type' => 'client_credentials',
        'scopes'      => ['payments', 'transactions.history', 'user.app-settings', 'user.profile_readonly']
    ]);
    $accessToken = $sumup->getAccessToken();
    $value = $accessToken->getValue();
    error_log("ACCESS TOKEN=" . $value);

    $sumup = new \SumUp\SumUp([
        'app_id'     => get_option('cws_sumup_key'),
        'app_secret' => get_option('cws_sumup_secret_key'),
        'access_token' => $value
    ]);

    $checkoutsService = $sumup->getCheckoutService();

//     WORKING FINE TO THIS POINT

    $response = $checkoutsService->create(10, 'GBP', 'DYS00001', '[email protected]');
    $checkoutId = $response->getBody()->id;


} catch (\SumUp\Exceptions\SumUpAuthenticationException $e) {
    echo 'Authentication error: ' . $e->getMessage();
} catch (\SumUp\Exceptions\SumUpResponseException $e) {
    echo 'Response error: ' . $e->getMessage();
} catch(\SumUp\Exceptions\SumUpSDKException $e) {
    echo 'SumUp SDK error: ' . $e->getMessage();
}

I am getting an access token and the checkout service seems to work but I'm getting
Response error: request_not_allowed

with the create method. This is taking too much time and I need to get it sorted. Please help. Is there a better PHP guide or a sample app that I can take a look at.

Thanks

SumUpResponseException Client error

Hello,

I had this error when trying to connect with this code
$sumup = new \SumUp\SumUp([
'app_id' => $client_id,
'app_secret' => $client_secret,
'grant_type' => 'password',
'scopes' => ['payments', 'transactions.history', 'user.app-settings', 'user.profile_readonly'],
'username' => $sumupEmail,
'password' => $sumupPwd
]);

Everything was working fine for months and tonight I got an SumUpResponseException and this message on the response :

"Client error" 
=> Too many requests, please try again later.))[2] => Array([file] => /homepages/

I noticed that the sumup server regulary have pb on we.
Could you please tell me how or when this issue will be solved ?

Many thanks in advance.

SumUp SDK error: Internal Server Error (3imsx1wj4pebs)

Hello we have a connection problem with the server. We use this official class code in php to connect but it returns the error attached. You can help us ? Thanks in advance. Best regards

$sumup = new \SumUp\SumUp([
'app_id' => 'cc_classic_0JgS[edited]',
'app_secret' => 'cc_sk_classic_h3tRjaoz[edited]',
'grant_type' => 'client_credentials',
'scopes' => ['user.profile', 'transactions.history', 'user.app-settings', 'user.profile_readonly']
]);
$accessToken = $sumup->getAccessToken();
$merchantService = $sumup->getTransactionService($accessToken);
dd($merchantService->getTransactionHistory());
Screenshot 2022-10-12 at 09-22-39 🧨 Internal Server Error (r9av1jpszylc)

PS: Edited your message to remove sensible data from open internet.

getting 403 error in checkout api

i am getting [error_message] => request_not_allowed [error_code] => FORBIDDEN [status_code] => 403
Here is mycode
function getTokenU()
{
$headers = [
'Content-Type: application/json',
];
$packet = [
'grant_type' => 'client_credentials',
'client_id' => $client_id,
'client_secret' => $client_secret,
//'scope' => ['payments', 'transactions.history', 'user.app-settings', 'user.profile_readonly'],
];
$packet_json = json_encode($packet);
$ch = curl_init();
$ch = curl_init('https://api.sumup.com/token');
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'POST');
curl_setopt($ch, CURLOPT_POSTFIELDS, $packet_json);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
$output = curl_exec($ch);
$output = json_decode($output, true);

    return $output['access_token'];

}

$token = getTokenU();

$amount = '100';
$currency = 'EUR';
$checkoutRef = '0'.uniqid();
$payToEmail = '[email protected]';
 $packet = [
        'checkout_reference' => 'O_'.uniqid(),
        'amount' => 2.00,
        'currency' => 'EUR',
        'pay_to_email' => $payToEmail,
        'return_url' => 'success.php',
        
    ];
    $headers = [
        'Content-Type: application/json',
        'Authorization: Bearer '.$token,
    ];
    $packet_json = json_encode($packet);
    $ch = curl_init();
    $ch = curl_init('https://api.sumup.com/v0.1/checkouts');
    curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'POST');
    curl_setopt($ch, CURLOPT_POSTFIELDS, $packet_json);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
    $output = curl_exec($ch);
    $output = json_decode($output, true);

    print_r($output);

// and i am getting
Array ( [error_message] => request_not_allowed [error_code] => FORBIDDEN [status_code] => 403 )

No documentation that actually works for creating YOUR-AUTHORIZATION-CODE

This page (https://github.com/sumup/sumup-ecom-php-sdk/blob/master/docs/HowToAuthorize.md) says you need to put in YOUR-AUTHORIZATION-CODE that you obtained from authorizing a merchant.

However, I use the linked example on obtaining such a code (https://developer.sumup.com/docs/authorization#authorization-code-flow) and redirect the user to the following url:
https://api.sumup.com/authorize?response_type=code&client_id=XXXXXX&redirect_uri=XXXXXX&scope=payments%20user.app-settings%20transactions.history%20user.profile_readonly&state=XXXXXX

Obviously, the XXXXX are replaced with real values.... By redirecting to that url, I get a 200 return code with no text or payload. So there is no way to obtain a code and use the API.

So my question is twofold, what is the proper way to get this auth code and can it be done through the PHP API?

SSL Certificate problem

I have an Laravel API configured with:

"php": "^7.3",
"fideloper/proxy": "^4.2",
"fruitcake/laravel-cors": "^2.0",
"guzzlehttp/guzzle": "^7.0.1",
"laravel/framework": "^8.0",
"laravel/sanctum": "^2.15",
"laravel/tinker": "^2.0",
"sumup/sumup-ecom-php-sdk": "^1.1",
"symfony/http-client": "^5.4",
"symfony/mailgun-mailer": "^5.4"

When I request to the Sumup API from my Laravel project the error message shows these lines:

SumUp\Exceptions\SumUpConnectionException: SSL certificate problem: unable to get local issuer certificate in file C:\Projetos\Php\api-laravel-intelligent\vendor\sumup\sumup-ecom-php-sdk\src\SumUp\HttpClients\SumUpCUrlClient.php on line 74

#0 C:\Projetos\Php\api-laravel-intelligent\vendor\sumup\sumup-ecom-php-sdk\src\SumUp\Services\Authorization.php(141): SumUp\HttpClients\SumUpCUrlClient->send('POST', '/token', Array, Array)
#1 C:\Projetos\Php\api-laravel-intelligent\vendor\sumup\sumup-ecom-php-sdk\src\SumUp\Services\Authorization.php(83): SumUp\Services\Authorization->getTokenByClientCredentials()
#2 C:\Projetos\Php\api-laravel-intelligent\vendor\sumup\sumup-ecom-php-sdk\src\SumUp\SumUp.php(57): SumUp\Services\Authorization->getToken()
#3 C:\Projetos\Php\api-laravel-intelligent\app\Http\Controllers\LicenseController.php(17): SumUp\SumUp->__construct(Array)
#4 C:\Projetos\Php\api-laravel-intelligent\vendor\laravel\framework\src\Illuminate\Routing\Controller.php(54): App\Http\Controllers\LicenseController->payment(Object(Illuminate\Http\Request))
#5 C:\Projetos\Php\api-laravel-intelligent\vendor\laravel\framework\src\Illuminate\Routing\ControllerDispatcher.php(45): Illuminate\Routing\Controller->callAction('payment', Array)
#6 C:\Projetos\Php\api-laravel-intelligent\vendor\laravel\framework\src\Illuminate\Routing\Route.php(262): Illuminate\Routing\ControllerDispatcher->dispatch(Object(Illuminate\Routing\Route), Object(App\Http\Controllers\LicenseController), 'payment')
#7 C:\Projetos\Php\api-laravel-intelligent\vendor\laravel\framework\src\Illuminate\Routing\Route.php(205): Illuminate\Routing\Route->runController()
#8 C:\Projetos\Php\api-laravel-intelligent\vendor\laravel\framework\src\Illuminate\Routing\Router.php(721): Illuminate\Routing\Route->run()
#9 C:\Projetos\Php\api-laravel-intelligent\vendor\laravel\framework\src\Illuminate\Pipeline\Pipeline.php(128): Illuminate\Routing\Router->Illuminate\Routing{closure}(Object(Illuminate\Http\Request))
#10 C:\Projetos\Php\api-laravel-intelligent\vendor\laravel\framework\src\Illuminate\Routing\Middleware\SubstituteBindings.php(50): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline{closure}(Object(Illuminate\Http\Request))
#11 C:\Projetos\Php\api-laravel-intelligent\vendor\laravel\framework\src\Illuminate\Pipeline\Pipeline.php(167): Illuminate\Routing\Middleware\SubstituteBindings->handle(Object(Illuminate\Http\Request), Object(Closure))
#12 C:\Projetos\Php\api-laravel-intelligent\vendor\laravel\framework\src\Illuminate\Routing\Middleware\ThrottleRequests.php(127): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline{closure}(Object(Illuminate\Http\Request))
#13 C:\Projetos\Php\api-laravel-intelligent\vendor\laravel\framework\src\Illuminate\Routing\Middleware\ThrottleRequests.php(103): Illuminate\Routing\Middleware\ThrottleRequests->handleRequest(Object(Illuminate\Http\Request), Object(Closure), Array)
#14 C:\Projetos\Php\api-laravel-intelligent\vendor\laravel\framework\src\Illuminate\Routing\Middleware\ThrottleRequests.php(55): Illuminate\Routing\Middleware\ThrottleRequests->handleRequestUsingNamedLimiter(Object(Illuminate\Http\Request), Object(Closure), 'api', Object(Closure))
#15 C:\Projetos\Php\api-laravel-intelligent\vendor\laravel\framework\src\Illuminate\Pipeline\Pipeline.php(167): Illuminate\Routing\Middleware\ThrottleRequests->handle(Object(Illuminate\Http\Request), Object(Closure), 'api')
#16 C:\Projetos\Php\api-laravel-intelligent\vendor\laravel\framework\src\Illuminate\Auth\Middleware\Authenticate.php(44): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline{closure}(Object(Illuminate\Http\Request))
#17 C:\Projetos\Php\api-laravel-intelligent\vendor\laravel\framework\src\Illuminate\Pipeline\Pipeline.php(167): Illuminate\Auth\Middleware\Authenticate->handle(Object(Illuminate\Http\Request), Object(Closure), 'sanctum')
#18 C:\Projetos\Php\api-laravel-intelligent\vendor\laravel\sanctum\src\Http\Middleware\EnsureFrontendRequestsAreStateful.php(33): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline{closure}(Object(Illuminate\Http\Request))
#19 C:\Projetos\Php\api-laravel-intelligent\vendor\laravel\framework\src\Illuminate\Pipeline\Pipeline.php(128): Laravel\Sanctum\Http\Middleware\EnsureFrontendRequestsAreStateful->Laravel\Sanctum\Http\Middleware{closure}(Object(Illuminate\Http\Request))
#20 C:\Projetos\Php\api-laravel-intelligent\vendor\laravel\framework\src\Illuminate\Pipeline\Pipeline.php(103): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline{closure}(Object(Illuminate\Http\Request))
#21 C:\Projetos\Php\api-laravel-intelligent\vendor\laravel\sanctum\src\Http\Middleware\EnsureFrontendRequestsAreStateful.php(34): Illuminate\Pipeline\Pipeline->then(Object(Closure))
#22 C:\Projetos\Php\api-laravel-intelligent\vendor\laravel\framework\src\Illuminate\Pipeline\Pipeline.php(167): Laravel\Sanctum\Http\Middleware\EnsureFrontendRequestsAreStateful->handle(Object(Illuminate\Http\Request), Object(Closure))
#23 C:\Projetos\Php\api-laravel-intelligent\vendor\laravel\framework\src\Illuminate\Pipeline\Pipeline.php(103): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline{closure}(Object(Illuminate\Http\Request))
#24 C:\Projetos\Php\api-laravel-intelligent\vendor\laravel\framework\src\Illuminate\Routing\Router.php(723): Illuminate\Pipeline\Pipeline->then(Object(Closure))
#25 C:\Projetos\Php\api-laravel-intelligent\vendor\laravel\framework\src\Illuminate\Routing\Router.php(698): Illuminate\Routing\Router->runRouteWithinStack(Object(Illuminate\Routing\Route), Object(Illuminate\Http\Request))
#26 C:\Projetos\Php\api-laravel-intelligent\vendor\laravel\framework\src\Illuminate\Routing\Router.php(662): Illuminate\Routing\Router->runRoute(Object(Illuminate\Http\Request), Object(Illuminate\Routing\Route))
#27 C:\Projetos\Php\api-laravel-intelligent\vendor\laravel\framework\src\Illuminate\Routing\Router.php(651): Illuminate\Routing\Router->dispatchToRoute(Object(Illuminate\Http\Request))
#28 C:\Projetos\Php\api-laravel-intelligent\vendor\laravel\framework\src\Illuminate\Foundation\Http\Kernel.php(167): Illuminate\Routing\Router->dispatch(Object(Illuminate\Http\Request))
#29 C:\Projetos\Php\api-laravel-intelligent\vendor\laravel\framework\src\Illuminate\Pipeline\Pipeline.php(128): Illuminate\Foundation\Http\Kernel->Illuminate\Foundation\Http{closure}(Object(Illuminate\Http\Request))
#30 C:\Projetos\Php\api-laravel-intelligent\vendor\laravel\framework\src\Illuminate\View\Middleware\ShareErrorsFromSession.php(49): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline{closure}(Object(Illuminate\Http\Request))
#31 C:\Projetos\Php\api-laravel-intelligent\vendor\laravel\framework\src\Illuminate\Pipeline\Pipeline.php(167): Illuminate\View\Middleware\ShareErrorsFromSession->handle(Object(Illuminate\Http\Request), Object(Closure))
#32 C:\Projetos\Php\api-laravel-intelligent\vendor\laravel\framework\src\Illuminate\Session\Middleware\StartSession.php(121): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline{closure}(Object(Illuminate\Http\Request))
#33 C:\Projetos\Php\api-laravel-intelligent\vendor\laravel\framework\src\Illuminate\Session\Middleware\StartSession.php(64): Illuminate\Session\Middleware\StartSession->handleStatefulRequest(Object(Illuminate\Http\Request), Object(Illuminate\Session\Store), Object(Closure))
#34 C:\Projetos\Php\api-laravel-intelligent\vendor\laravel\framework\src\Illuminate\Pipeline\Pipeline.php(167): Illuminate\Session\Middleware\StartSession->handle(Object(Illuminate\Http\Request), Object(Closure))
#35 C:\Projetos\Php\api-laravel-intelligent\vendor\laravel\framework\src\Illuminate\Foundation\Http\Middleware\TransformsRequest.php(21): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline{closure}(Object(Illuminate\Http\Request))
#36 C:\Projetos\Php\api-laravel-intelligent\vendor\laravel\framework\src\Illuminate\Foundation\Http\Middleware\ConvertEmptyStringsToNull.php(31): Illuminate\Foundation\Http\Middleware\TransformsRequest->handle(Object(Illuminate\Http\Request), Object(Closure))
#37 C:\Projetos\Php\api-laravel-intelligent\vendor\laravel\framework\src\Illuminate\Pipeline\Pipeline.php(167): Illuminate\Foundation\Http\Middleware\ConvertEmptyStringsToNull->handle(Object(Illuminate\Http\Request), Object(Closure))
#38 C:\Projetos\Php\api-laravel-intelligent\vendor\laravel\framework\src\Illuminate\Foundation\Http\Middleware\TransformsRequest.php(21): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline{closure}(Object(Illuminate\Http\Request))
#39 C:\Projetos\Php\api-laravel-intelligent\vendor\laravel\framework\src\Illuminate\Foundation\Http\Middleware\TrimStrings.php(40): Illuminate\Foundation\Http\Middleware\TransformsRequest->handle(Object(Illuminate\Http\Request), Object(Closure))
#40 C:\Projetos\Php\api-laravel-intelligent\vendor\laravel\framework\src\Illuminate\Pipeline\Pipeline.php(167): Illuminate\Foundation\Http\Middleware\TrimStrings->handle(Object(Illuminate\Http\Request), Object(Closure))
#41 C:\Projetos\Php\api-laravel-intelligent\vendor\laravel\framework\src\Illuminate\Foundation\Http\Middleware\ValidatePostSize.php(27): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline{closure}(Object(Illuminate\Http\Request))
#42 C:\Projetos\Php\api-laravel-intelligent\vendor\laravel\framework\src\Illuminate\Pipeline\Pipeline.php(167): Illuminate\Foundation\Http\Middleware\ValidatePostSize->handle(Object(Illuminate\Http\Request), Object(Closure))
#43 C:\Projetos\Php\api-laravel-intelligent\vendor\laravel\framework\src\Illuminate\Foundation\Http\Middleware\PreventRequestsDuringMaintenance.php(86): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline{closure}(Object(Illuminate\Http\Request))
#44 C:\Projetos\Php\api-laravel-intelligent\vendor\laravel\framework\src\Illuminate\Pipeline\Pipeline.php(167): Illuminate\Foundation\Http\Middleware\PreventRequestsDuringMaintenance->handle(Object(Illuminate\Http\Request), Object(Closure))
#45 C:\Projetos\Php\api-laravel-intelligent\vendor\fruitcake\laravel-cors\src\HandleCors.php(52): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline{closure}(Object(Illuminate\Http\Request))
#46 C:\Projetos\Php\api-laravel-intelligent\vendor\laravel\framework\src\Illuminate\Pipeline\Pipeline.php(167): Fruitcake\Cors\HandleCors->handle(Object(Illuminate\Http\Request), Object(Closure))
#47 C:\Projetos\Php\api-laravel-intelligent\vendor\fideloper\proxy\src\TrustProxies.php(57): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline{closure}(Object(Illuminate\Http\Request))
#48 C:\Projetos\Php\api-laravel-intelligent\vendor\laravel\framework\src\Illuminate\Pipeline\Pipeline.php(167): Fideloper\Proxy\TrustProxies->handle(Object(Illuminate\Http\Request), Object(Closure))
#49 C:\Projetos\Php\api-laravel-intelligent\vendor\laravel\framework\src\Illuminate\Pipeline\Pipeline.php(103): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline{closure}(Object(Illuminate\Http\Request))
#50 C:\Projetos\Php\api-laravel-intelligent\vendor\laravel\framework\src\Illuminate\Foundation\Http\Kernel.php(142): Illuminate\Pipeline\Pipeline->then(Object(Closure))
#51 C:\Projetos\Php\api-laravel-intelligent\vendor\laravel\framework\src\Illuminate\Foundation\Http\Kernel.php(111): Illuminate\Foundation\Http\Kernel->sendRequestThroughRouter(Object(Illuminate\Http\Request))
#52 C:\Projetos\Php\api-laravel-intelligent\public\index.php(52): Illuminate\Foundation\Http\Kernel->handle(Object(Illuminate\Http\Request))
#53 C:\Projetos\Php\api-laravel-intelligent\server.php(21): require_once('C:\Projetos\Php...')
#54 {main}
-->

Class not found : ApplicationConfiguration

I've created an index file from where i'am using SumUp class of SumUp.php file from sumup folder, And i'am getting the following error from SumUp.php file:

Fatal error: Uncaught Error: Class 'SumUp\Application\ApplicationConfiguration' not found in /mnt/stor1-wc1-dfw1/388632/www.xyz.com/web/content/wilson/sumup/sumup/SumUp.php:54 Stack trace: #0 /mnt/stor1-wc1-dfw1/388632/www.xyz.com/web/content/wilson/sumup/index.php(23): SumUp\SumUp->__construct(Array) #1 {main} thrown in /mnt/stor1-wc1-dfw1/388632/www.xyz.com/web/content/wilson/sumup/sumup/SumUp.php on line 54

JS console deprecation warning

Warning is :

sdk.js:462 The configuration property 'amount' is deprecated. Please use the 'showAmount' configuration. The checkout amount will be fetched from our API using the given checkoutId

Script is being included with :

<script src="https://gateway.sumup.com/gateway/ecom/card/v2/sdk.js"></script>

In passing, the returns from the API are pretty much useless. Payments are failing, but with absolutely no indication being returned as to why.

Error if wrong grant_type

In setGrantType() method of class SumUp\Application\ApplicationConfiguration, if you pass an invalid granttype, an exception is thrown. But, you will get a TypeError instead of the expected exception, since the call to implode() is not valid for php 8:
The separator is passed after the array, which was only valid up until php 7.

SDK not working on shared hosting

I am facing this weird issue. I tried the sdk on local system, where it is working fine. When I move the code to live server, it stopped working. The live server not getting the response from api.sumup.com.

Is their any criteria that sumup server blocks the domain from accessing it or it might have any other issue. I checked the error logs and do not find any error in requesting the api.

<?php 
require_once('vendor/autoload.php');
try {
    $sumup = new \SumUp\SumUp([
        'app_id'     => 'xxxxx',
        'app_secret' => 'xxxx',
        'grant_type' => 'client_credentials',
        'scopes'      => ['payments']
    ]);
    $checkoutService = $sumup->getCheckoutService();
    $checkoutResponse = $checkoutService->create(1,'USD', 'ASDASDSAD', '[email protected]');
    $checkoutId = $checkoutResponse->getBody()->id;

    echo $checkoutId;die;
//  pass the $chekoutId to the front-end to be processed
} catch (\SumUp\Exceptions\SumUpAuthenticationException $e) {
    echo 'Authentication error: ' . $e->getMessage();
} catch (\SumUp\Exceptions\SumUpResponseException $e) {
    echo 'Response error: ' . $e->getMessage();
} catch(\SumUp\Exceptions\SumUpSDKException $e) {
    echo 'SumUp SDK error: ' . $e->getMessage();
}

PHP 8 support

Hi,

It would be nice to add support to PHP 8 :)

Best regards

error creating a checkout in a php page

hello every one
im trying to create a simple php page that includes your card widget, so from my website i redirect the users to this page to make the payment online.

i started to get the authentication code and then the checkout id code but i keep getting this error:

Notice: Undefined property: stdClass::$access_token in E:\Inetpub\wwwroot\secure.lelepetshop.it\test\vendor\sumup\sumup-ecom-php-sdk\src\SumUp\Services\Authorization.php on line 119

Notice: Undefined property: stdClass::$token_type in E:\Inetpub\wwwroot\secure.lelepetshop.it\test\vendor\sumup\sumup-ecom-php-sdk\src\SumUp\Services\Authorization.php on line 119

Notice: Undefined property: stdClass::$expires_in in E:\Inetpub\wwwroot\secure.lelepetshop.it\test\vendor\sumup\sumup-ecom-php-sdk\src\SumUp\Services\Authorization.php on line 119

Notice: Undefined property: stdClass::$refresh_token in E:\Inetpub\wwwroot\secure.lelepetshop.it\test\vendor\sumup\sumup-ecom-php-sdk\src\SumUp\Services\Authorization.php on line 119
Authentication error: access token required

here's the code i use as a test:

`require_once("vendor/autoload.php");

function get_auth_code(){
try {
$sumup = new \SumUp\SumUp([
'grant_type' => 'client_credentials',
'app_id' => 'xxxxxxxxxxxxxxxxxxxxxx',
'app_secret' => 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx',
'scope' => ['payments']
]);
$accessToken = $sumup->getAccessToken();
$value = $accessToken->getValue();
return $value;
// pass the $chekoutId to the front-end to be processed
} catch (\SumUp\Exceptions\SumUpAuthenticationException $e) {
echo 'Authentication error: ' . $e->getMessage();
} catch (\SumUp\Exceptions\SumUpResponseException $e) {
echo 'Response error: ' . $e->getMessage();
} catch(\SumUp\Exceptions\SumUpSDKException $e) {
echo 'SumUp SDK error: ' . $e->getMessage();
}
}

try {
$code_auth = get_auth_code();
$sumup = new \SumUp\SumUp([
'app_id' => 'xxxxxxxxxxxxxxxxxx',
'app_secret' => 'xxxxxxxxxxxxxxxxxx',
'code' => $code_auth
]);

$amount = "1";
$currency = "EUR";
$checkoutRef ="1";
$payToEmail="[email protected]";

$checkoutService = $sumup->getCheckoutService();
$checkoutResponse = $checkoutService->create($amount, $currency, $checkoutRef, $payToEmail);
$checkoutId = $checkoutResponse->getBody()->id;

// pass the $chekoutId to the front-end to be processed
} catch (\SumUp\Exceptions\SumUpAuthenticationException $e) {
echo 'Authentication error: ' . $e->getMessage();
} catch (\SumUp\Exceptions\SumUpResponseException $e) {
echo 'Response error: ' . $e->getMessage();
} catch(\SumUp\Exceptions\SumUpSDKException $e) {
echo 'SumUp SDK error: ' . $e->getMessage();
}`

Most transactions fails when using sdk or REST API v0.2

I created checkout page using Payment Widget sdk like the following:

<div id="sumup-card">

<script src="https://gateway.sumup.com/gateway/ecom/card/v2/sdk.js"></script>
<script>
var sumupcard = SumUpCard.mount({
    checkoutId: checkoutId,
    showAmount: true,
    showFooter: true,
    locale: "de-DE",
    onResponse: function(type, body) {
        if (type=="success") {
            console.log(body);
        }
    },
});
</script>

When I click the submit button, the request is sent to https://api.sumup.com/v0.2/checkouts/:id
image
Transactions almost always fail. Most transactions fail. I wonder if v0.2 is the reason.
So I tried to process checkouts via REST API v0.2 instead of v0.1.
The result is same as sdk. But the transactions always succeed via v0.1.
Who can let me know the url of sumup-card widget sdk file using v0.1 if it exist?

403 error posting a checkout request

I really cannot figure out how to create a checkout request
`
try {
$sumup = new \SumUp\SumUp([
'app_id' => $app_config['app_id'],
'app_secret' => $app_config['app_secret'],
'grant_type' => 'client_credentials',
'scopes' => ['payments', 'transactions.history', 'user.app-settings', 'user.profile_readonly'],
'use_guzzlehttp_over_curl' => $app_config['force_guzzle'],
]);

$accessToken = $sumup->getAccessToken();
$value = $accessToken->getValue();

$checkoutsService = $sumup->getCheckoutService();

$response = $checkoutsService->create(10, 'EUR', 'CO746453', '[email protected]', 'Sample one-time payment');

$checkoutId = $response->getBody()->id;
stampa_info('CHECKOUT ID: '.$checkoutId);

} catch (\SumUp\Exceptions\SumUpValidationException $e) {
die(stampa_errore('Validation error: ' . $e->getMessage() . ' - Code: '.$e->getCode()));
} catch (\SumUp\Exceptions\SumUpArgumentException $e) {
die(stampa_errore('Argument error: ' . $e->getMessage() . ' - Code: '.$e->getCode()));
} catch (\SumUp\Exceptions\SumUpAuthenticationException $e) {
die(stampa_errore('Authentication error: ' . $e->getMessage() . ' - Code: '.$e->getCode()));
} catch (\SumUp\Exceptions\SumUpResponseException $e) {
die(stampa_errore('Response error: ' . $e->getMessage() . ' - Code: '.$e->getCode()));
} catch(\SumUp\Exceptions\SumUpSDKException $e) {
die(stampa_errore('SumUp SDK error message: ' . $e->getMessage() . ' - Code: '.$e->getCode()));
} catch(\SumUp\Exceptions\SumUpServerException $e) {
die(stampa_errore('SumUp server error message: ' . $e->getMessage() . ' - Code: '.$e->getCode()));
} catch (Exception $e){
die(stampa_errore('Si è verificato un problema: ' . $e->getMessage() . ' - Code: '.$e->getCode()));
}
`

I get a "Response error: request_not_allowed - Code: 403" exception.
I am sure that $accessToken has a value. So I cannot figure why it's not working.

403 - Account temporary locked is not handled properly

Accessing an account that is temporary locked (due to too many failed logins) results in a SumUp\HttpClients\Response of:

object(SumUp\HttpClients\Response)#261 (2) { ["httpResponseCode":protected]=> int(403) ["body":protected]=> object(stdClass)#268 (2) { ["error_message"]=> string(24) "Account temporary locked" ["error_code"]=> string(16) "TEMPORARY_LOCKED" } }

This isn't properly handled in the following file (line 102) and results in null being passed to SumUpResponseException which results in a Fatal Error.

if ($this->httpResponseCode >= 400) {
$message = (!is_null($this->body) && !is_null($this->body->message)) ? $this->body->message : $this->body;
throw new SumUpResponseException($message, $this->httpResponseCode);
}

Error Detail:

Fatal error: Uncaught Error: Wrong parameters for SumUp\Exceptions\SumUpResponseException([string $message [, long $code [, Throwable $previous = NULL]]]) in vendor/sumup/sumup-ecom-php-sdk/src/SumUp/HttpClients/Response.php:103 Stack trace: #0 vendor/sumup/sumup-ecom-php-sdk/src/SumUp/HttpClients/Response.php(103): Exception->__construct(Object(stdClass), 403)

Make a webhook

I have a website there is only one button called purchases. When it is clicked, it will redirect to this page: https://cafe-369.sumupstore.com/product/test-01

The customer will select the variant and will do the payment. once payment is successful it should redirect back to the main website. so I thought about using webhook but I am not sure I can do it with this workflow. So is there any way to do this?

More info: I am using php

Callback never called

Hi,

I use this sdk to generate checkout and accept payment on a mobile app via the sumup card widget that can be found here https://developer.sumup.com/docs/widgets-card/

My process is the following :

  1. The user open my app and press the "Pay by card" button : a request to the server is done to generate the checkout thanks to this sdk and I indicate a callback URL like this
    $checkoutService = $sumup->getCheckoutService();
    $checkoutResponse = $checkoutService->create($amount, $currency, $checkoutRef, $payToEmail, $emailClient, null, $callBackUrl);

  2. The checkout id is retreived and the url of the page containing the card widget is generated and displayed on a webview on my app

  3. The user enter his card number, the validation is done and the user is asked to validate the 3DS process

  4. Some users must validate the 3DS process on their bank app => MY mobile app is on background

The pb is if the user never reopen my app, the payment is never validated because the callback is never called.

Is there a way to make the process completed even if the user never re open my app and display the webview to complete the process ?

Many thanks in advance.

Wy i have response 400 ?

Hello, i have problem,

I followed the documentation to make a payment except that it doesn't work, I use the php sdk, here is an extract of 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', 'payment_instruments', 'transactions.history', 'user.app-settings', 'user.profile_readonly'],
        ]);

// $checkoutsService = $sumup->getCheckoutService();
// $response = $checkoutsService->create(20, 'EUR', 'C4F45478R', '[email protected]', 'Sample one-time payment');
// $checkoutId = $response->getBody()->id;
// dump($checkoutId);
$customService = $sumup->getCustomService();
$checkoutId = "17b5fb52-4c02-4c46-ad25-6a9a202a4402";
$response = $customService->request('PUT', "/v0.1/checkouts/{$checkoutId}", $data);
//$response = $customService->request('GET', '/v0.1/checkouts');
dump($response->getBody());
} catch (SumUpSDKException $exception) {
dd($exception);
}`

this is account test, wy the card john doe not work ? is return 400 for me ;

SumupApi.php on line 44:
SumUp\Exceptions\SumUpResponseException {#901 ▼
#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"
#line: 103

can you help me ? thanks for you response

SumUp integration in Php using Api's

try {
$sumup = new \SumUp\SumUp([
'app_id' => env('SUM_UP_APP_ID'),
'app_secret' => env('SUM_UP_APP_SECRET'),
'grant_type' => 'client_credentials',
'scopes' => ['payments', 'transactions.history', 'user.app-settings', 'user.profile_readonly'],
]);
$checkoutService = $sumup->getCheckoutService();
// $checkoutResponse = $checkoutService->create($amount, $currency, $checkoutRef, $payToEmail);
// $checkoutId = $checkoutResponse->getBody()->id;
$success = [
'message' => 'Get Sum Up Auth.',
'success' =>true,
'data' => $checkoutService
];
// pass the $chekoutId to the front-end to be processed
} catch (\SumUp\Exceptions\SumUpAuthenticationException $e) {
$success = [
'message' => 'Authentication error: ' . $e->getMessage(),
'success' =>false,
];
} catch (\SumUp\Exceptions\SumUpResponseException $e) {
$success = [
'message' => 'Response error: ' . $e->getMessage(),
'success' =>false,
];
} catch(\SumUp\Exceptions\SumUpSDKException $e) {
$success = [
'message' => 'SumUp SDK error: ' . $e->getMessage(),
'success' =>false,
];
}

This is my api code ,I want to create a checkout api but I'm face response error,
So, give me suggestion how to fix this error.

error compsoser

Hi,
Iḿ trying get SKD summup to php excute this command:
composer require sumup/sumup-ecom-php-sdk
and return is
Package sumup/sumup-ecom-php-sdk has a PHP requirement incompatible with your PHP version, PHP extensions and Composer version

php version 8.0.5 and composer version2.0

Documentation Typo

Docs > Checkouts.md > delete method
The parameter that must be supplied is the checkoutId as stated in the code example, not the checkout_reference_id.

licence

You might not accept Pull Requests but I submitted one anyway so that other users like myself can actually read your licence #16

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.