Checkout redirect URL

Once the customer decides to checkout with Raylo Pay, they should be redirected to raylopay.com with all the required checkout information.

You can get the SDK to produce a redirect URL in the following way:

// header...
use \Raylo\RayloPay\SDK\Checkout;
use \Raylo\RayloPay\SDK\CheckoutCreationData;
use \Raylo\RayloPay\SDK\Price as RayloPrice;

// initialisation/constructor...
$config = new ConfigProvider(...);
$urlProvider = new MerchantUrlProvider($config);
$checkout = new Checkout($config, $urlProvider);

// function/method body...
$requestData = new CheckoutCreationData;
$requestData->currency = 'GBP';

$requestData->customerInfo->firstName = ...;
$requestData->customerInfo->lastName = ...;
$requestData->customerInfo->email = ...;
$requestData->customerInfo->mobilePhoneNumber = ...;

$requestData->address->line1 = ...;
$requestData->address->line2 = ...;
$requestData->address->line3 = ...;
$requestData->address->city = ...;
$requestData->address->postcode = ...;
$requestData->address->region = ...;
$requestData->address->countryIsoAlpha2 = 'GB';

$orderLine = new OrderLine;
$orderLine->variant->reference = ... SKU ...;
$orderLine->variant->displayName = ...;

$orderLine->merchantPrice = new RayloPrice;
$orderLine->merchantPrice->valueAfterTax = ...;
$orderLine->merchantPrice->valueBeforeTax = ...;
$orderLine->merchantPrice->calcTaxValueAndPercentage();

// NB: Raylo Pay only supports one top level item right now,
// other items have to be added as add-ons using $orderLine->addons
$requestData->items[] = $orderLine;

$requestData->deliveryCost = new RayloPrice;
$requestData->deliveryCost->valueAfterTax = ...;
$requestData->deliveryCost->valueBeforeTax = ...;
$requestData->deliveryCost->calcTaxValueAndPercentage();

return $checkout->getCheckoutRedirectUrl($requestData);

Last updated

Was this helpful?