Coder Social home page Coder Social logo

sumup-php's Introduction

SumUp PHP SDK

Build Status Latest Stable Version Total Downloads Latest Unstable Version License

This is a work in progress package

Requirements

PHP 5.6 and later.

Composer

You can install the bindings via Composer. Run the following command:

composer require alexcode/sumup-php

Basic Usage

Setup your credentials

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

OAuth

As a merchant, you will need to Authorize your app to make requests on your behalf with OAuth

Authorization Code Grant

Get the authorize Url to redirect your merchant to.

SumUp doc Authorization Code Grant

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

Upon accepting the dialog, the merchant browser will hit your redirect URI with the code in the GET parameter (ex: http://MY_OAUTH_REDIRECT/?code=246d97b0b730c61f5929drfb3a444948fd54c058d0416019)

Therefore, you can create an Access Token to act on behalf of your Merchant.

Get Access Token

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

Refresh Access Token

SumUp doc Refresh Tokens

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

Checkout

Create the checkout server-side

SumUp doc Create checkout API

$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

Complete the checkout client-side

Use the URL to complete the payment in the client browser. Therefore, no PCI data is ever hitting your server.

SumUp doc Complete checkout API

PUT https://api.sumup.com/v0.1/checkouts/123456

body:
{
  "payment_type": "card",
  "card": {
    "name": "...",
    "number": "...",
    "expiry_year": "...",
    "expiry_month": "...",
    "cvv": "..."
  }
}

Note that a checkout can be completed in a browser only from a domain that is present in your OAuth setup as an authorized javascript origin(s).

List of currently implemented SumUp API

Checkouts API

  • Create checkout
  • Complete checkout
  • Create customer
  • Get payment instruments
  • Create payment instrument
  • Disable payment instrument

Transactions API

  • Transaction history
  • Transaction details
  • Refund transaction
  • Receipt data

Accounts API

  • Get account
  • Get personal profile
  • Create personal profile
  • Get merchant profile
  • Create merchant profile
  • Get DBA
  • Edit DBA
  • Get Bank Accounts
  • Create Bank Accounts
  • Payouts Get settings
  • Payouts Edit settings
Accounts API Employee
  • Create Employee
  • Get Employees
  • Change employee credentials
Accounts API Shelf
  • Get shelves
  • Create shelf
  • Create shelf
  • Edit shelf
  • Delete shelf
Accounts API Product
  • Get products
  • Create product
  • Get product
  • Edit product
  • Delete product
  • Get product prices
  • Create product price
  • Get product price
  • Edit product price
  • Delete product price
Accounts API Application Settings
  • Application Get settings
  • Application Edit settings

Credits

This Library is loosely inspired from Stripe PHP

sumup-php's People

Contributors

alexcode avatar luizvaz avatar

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.