Exemplo n.º 1
0
 /** @depends test_it_can_create_a_mandate */
 function test_it_can_create_a_payment(Mandate $mandate)
 {
     $payment = (new Payment())->collect(1000, 'GBP')->using($mandate);
     $payment = $this->api->createPayment($payment);
     $this->assertInstanceOf('GoCardless\\Pro\\Models\\Payment', $payment);
     $this->assertNotNull($payment->getId());
     $this->assertNotNull($payment->getCreatedAt());
     $this->assertNotNull($payment->getChargeDate());
     $this->assertTrue($payment->isPendingSubmission());
     $this->assertSame(1000, $payment->getAmount());
     $this->assertSame('GBP', $payment->getCurrency());
     return $payment;
 }
Exemplo n.º 2
0
require __DIR__ . '/vendor/autoload.php';
use GuzzleHttp\Client;
use GoCardless\Pro\Api;
use GoCardless\Pro\Models\Customer;
use GoCardless\Pro\Models\CustomerBankAccount;
use GoCardless\Pro\Models\Creditor;
use GoCardless\Pro\Models\Mandate;
use GoCardless\Pro\Models\Payment;
/**
 * When you sign up for GoCardless pro you will be given an API key by default.
 * Navigate to the organisation area and scroll to the API section. Grab those keys!
 *
 * @link https://manage-sandbox.gocardless.com/organisation
 * @link https://developer.gocardless.com/pro/#overview-backwards-compatibility
 */
$api = new Api(new Client(), 'ACCESS_TOKEN', '2015-04-29');
/** On with the show */
$customer = (new Customer())->setFullName('David', 'Cameron')->setAddress('10 Downing Street', 'London', 'SW1A 2AA', 'GB');
$customer = $api->createCustomer($customer);
$account = (new CustomerBankAccount())->withAccountDetails('Mr D Cameron', '55997711', '200000', 'GB', $customer);
$account = $api->createCustomerBankAccount($account);
// You also get a creditor ID automatically when you sign up.
$mandate = new Mandate($account, Creditor::withId('CR123'));
$mandate = $api->createMandate($mandate);
/**
 * Now lets take some money!
 */
$payment = (new Payment())->collect(5000, 'GBP')->on('2015-02-16')->using($mandate);
$payment = $api->createPayment($payment);
$payment->isPendingSubmission();
// true