/ap-php-sdk

PHP SDK for AlternativePayments API

Primary LanguagePHPMIT LicenseMIT

PHP SDK for Alternative Payments RESTful API

Installation

Requirements

PHP 5.3.3 and later. cURL extension.

Developer Documentation

Official Alternative Payments RESTful API Reference

Composer

It's recommended to use composer or you can download the latest release.

composer require alternativepayments/alternativepayments

Usage

To load the Alternative Payments PHP SDK you have to include autoloader:

require_once '/path/to/your-project/vendor/autoload.php';

To use Alternative Payments PHP SDK you need to setup your secret integration key:

use AlternativePayments\Config;
Config :: setApiKey("sk_test_rHErfsdjgfk9.....lFbfdsgh3mv0M");

SEPA transaction request example:

require_once '../vendor/autoload.php';

use AlternativePayments\Config;
Config :: setApiKey("sk_test_rHErfsdjgfk9.....lFbfdsgh3mv0M");

$customer = new \AlternativePayments\Model\Customer();
$customer->setEmail("john.doe@example.com");
$customer->setCountry("BE");
$customer->setFirstName("John");
$customer->setLastName("Doe");
$payment = new \AlternativePayments\Model\Payment();
$payment->setPaymentOption("SEPA");
$payment->setHolder("John Doe");
$payment->setIBAN("BE88271080782541");
$transaction = new \AlternativePayments\Model\Transaction();
$transaction->setCustomer($customer);
$transaction->setPayment($payment);
$transaction->setAmount(4500);
$transaction->setCurrency("EUR");
$transaction->setDescription("test sepa php sdk");
$transaction->setMerchantPassThruData("test_sepa_123");
$transaction->setIPAddress("127.0.0.1");
$res = \AlternativePayments\Transaction :: post($transaction);

For more examples check samples folder.

License

Read License for more licensing information.