sumup / sumup-ecom-php-sdk

SumUp eCom PHP SDK
Other
41 stars 18 forks source link

getting 403 error in checkout api #24

Closed waseemakhtarapp closed 2 years ago

waseemakhtarapp commented 3 years ago

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 = 'developmentwertyuiop@sumup.com';
 $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 )

chrisreiter commented 3 years ago

I have the same issue. auth and refresh token requests work fine, but requesting a checkout leads to 403.

chrisreiter commented 3 years ago

additional hint: calling that (see curl below without any params) from command line with a valid token leads to 403 as well......so it seems the server does not care about the following parameters at all and blocks the request right after authentication curl -X POST https://api.sumup.com/v0.1/checkouts -H "Authorization: Bearer 35c6d6fea505842dc0bff2a326043efb329769ad565a1c36661..."

chrisreiter commented 3 years ago

i got feedback from the support team:) your account has to be enabled for checkouts.. So just write to the support team and you're helped :)

ptrovatelli commented 2 years ago

in my case I had to write to integration@sumup.com