PHP code example of alexcode / sumup-php

1. Go to this page and download the library: Download alexcode/sumup-php library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

alexcode / sumup-php example snippets


Sumup\Sumup::setClientSecret('MY_CLIENT_SECRET');
Sumup\Sumup::setClientId('MY_CLIENT_ID');
Sumup\Sumup::setRedirectUri('MY_OAUTH_REDIRECT');

Sumup\OAuth::authorizeUrl(['scope' => 'payments']);
// https://api.sumup.com/authorize?scope=payments&client_id=MY_CLIENT_ID&redirect_uri=MY_OAUTH_REDIRECT&response_type=code

$access_token = Sumup\OAuth::getToken([
  'grant_type' => 'authorization_code',
  'code' => '246d97b0b730c61f5929drfb3a444948fd54c058d0416019'
]);

$refreshed = Sumup\OAuth::refreshToken($access_token);

$checkout = Sumup\Checkout::create([
  'amount' => 20,
  'currency' => 'EUR',
  'checkout_reference' => 'MY_REF',
  'pay_to_email' => 'MY_CUSTOMER_EMAIL',
]);

echo $checkout->getCompleteUrl();
// https://api.sumup.com/v0.1/checkouts/123456
bash
composer