/** @group Exceptions */ function test_it_throws_an_exception_if_the_token_doesnt_have_permission() { $config = (require __DIR__ . '/../config.php'); if (!array_key_exists('readOnlyAccessToken', $config)) { $this->markTestSkipped('You must set a read only token in the $config[readOnlyAccessToken] to run this test'); } $this->setExpectedException('\\GoCardless\\Pro\\Exceptions\\AuthenticationException'); $api = new Api(new Client(), $config['readOnlyAccessToken'], $config['version']); $customer = $this->get_basic_customer(); $api->createCustomer($customer); }
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