<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
think.studio / laravel-gocardless-payment example snippets
public function register()
{
// Do not run default migrations
\GoCardlessPayment\GoCardlessPayment::ignoreMigrations();
// Do not use default routes provided by package
\GoCardlessPayment\GoCardlessPayment::ignoreRoutes();
// Override repository to get local customer
$this->app->singleton(LocalCustomerRepository::class, function (Application $app) {
return new MyCustomLocalCustomerRepository();
});
// Override Api functionality
$this->app->bind(Api::class, function (Application $app) {
return new CustomApi();
});
}
use GoCardlessPayment\MandateCheckout\BillingRequest;
use GoCardlessPayment\MandateCheckout\BillingRequestFlow;
use GoCardlessPayment\MandateCheckout\MandateCheckoutPage;
use GoCardlessPayment\MandateCheckout\MandateRequest;
use GoCardlessPayment\MandateCheckout\Metadata;
use GoCardlessPayment\MandateCheckout\ReturnUrls;
/** @var \GoCardlessPayment\Contracts\GoCardlessCustomer $user */
$user = getCurrentUser();
$url = MandateCheckoutPage::make(
BillingRequest::make()
->mandateRequest(
MandateRequest::make()
->scheme('bacs')
->verifyWhenAvailable()
),
BillingRequestFlow::make()
->returnUrls(ReturnUrls::make(route('example.route')))
)->useCustomer($user)->requestCheckoutUrl();
return Redirect::to($url);
use GoCardlessPayment\MandateCheckout\BillingRequest;
use GoCardlessPayment\MandateCheckout\BillingRequestFlow;
use GoCardlessPayment\MandateCheckout\MandateCheckoutPage;
use GoCardlessPayment\MandateCheckout\MandateRequest;
use GoCardlessPayment\MandateCheckout\Metadata;
use GoCardlessPayment\MandateCheckout\ReturnUrls;
$url = MandateCheckoutPage::make(
BillingRequest::make()
->mandateRequest(
MandateRequest::make()
->scheme('bacs')
->verifyWhenAvailable()
)->metadata(
Metadata::make()
->add('crm_user', $user->getKey())
)->links(Links::make()->addCustomer($user->gocardlessKey())),
BillingRequestFlow::make()
->prefilledCustomer(
PrefilledCustomer::make()
->givenName($user->first_name)
->familyName($user->last_name)
->email($user->email)
->postalCode($user->postalcode)
->addressLine1($user->street)
->addressLine2($user->locality)
->city($user->town)
->region($user->county)
->countryCode($user->country_code)
)
->returnUrls(ReturnUrls::make(route('example.route')))
)->requestCheckoutUrl();
return Redirect::to($url);