Class RedirectPurchaseRequest
Viva Payments Redirect (REST) Purchase Request
To complete a redirect payment is a 3 step process. The explanation is at this link: https://github.com/VivaPayments/API/wiki/Redirect-Checkout
1. Creation of the Payment Order
The code in this gateway plugin completes the payment order using the /api/orders endpoint.
2. Completion of the Payment Details (Redirection)
This is done by redirecting the customer to the Viva checkout page.
3. Confirmation of the Transaction
The customer lands back on your website at the URL defined in your vivapayments.com account under the Sources section. There is no completePurchase() call required.
Example
// Create a gateway for the Viva Payments REST Gateway // (routes to GatewayFactory::create) $gateway = Omnipay::create('VivaPayments_Redirect'); // Initialise the gateway $gateway->initialize(array( 'merchantId' => 'TEST', 'apiKey' => 'TEST', 'testMode' => true, // Or false when you are ready for live transactions )); // Do a purchase transaction on the gateway $transaction = $gateway->purchase(array( 'amount' => '10.00', 'transactionId' => 'TestPurchaseTransaction123456', 'clientIp' => $_SERVER['REMOTE_ADDR'], )); $response = $transaction->send(); // For a Redirect gateway request if ($response->isRedirect()) { echo "Gateway response is a redirect.\n"; $redirect_url = $response->getRedirectUrl(); echo "Redirect URL = $redirect_url\n"; $sale_id = $response->getTransactionReference(); echo "Transaction reference = " . $sale_id . "\n"; }
At the completion of this code the customer needs to be redirected to $redirect_url
Return to Your Website
Upon completion of the checkout form, the customer is redirected back to your website. The redirection URLs are defined in your vivapayments.com account under the Sources section.
Note that the redirection always happens at the 'Source' level. If you have defined multiple sources on your profile, you need to use the optional parameter 'SourceCode' when creating the order, so that the system selects the appropriate redirection url.
The redirection uses the HTTP GET method and may append the following parameters to the URL:
- s (int64): The Payment Order unique 12 digit ID
- t (uuid): The Transaction ID (may not be returned for some failed transactions)
- Lang (string): The language of the destination page in ISO format (el-GR for Greek, en-US for English)
NOTE: It is highly recommended you always verify the status of a transaction and not blindly depend on whether your success or failure url is called. You can make a GetTransactions call to verify the status of an Order. To get notified for offline payment methods you can make use of the Webhooks notification service.
The Transaction ID in the redirect GET parameter is the transactionReference that has to be used for subsequent refund() requests, not the transactionReference used in this purchase() call.
You may also see this TransactionID in the Transaction Details page in the vivapayments.com account under "My Sales -> Sales" (click on the "Info" link).
- Omnipay\Common\Message\AbstractRequest implements Omnipay\Common\Message\RequestInterface
- Omnipay\VivaPayments\Message\AbstractRestRequest
- Omnipay\VivaPayments\Message\RedirectPurchaseRequest
Direct known subclasses
Omnipay\VivaPayments\Message\RedirectAuthorizeRequestSee:
Omnipay\VivaPayments\RestGateway
Link: https://github.com/VivaPayments/API/wiki
Link: https://www.vivawallet.com/en-us/company
Link: https://github.com/VivaPayments/API/wiki/Redirect-Checkout
Located at Message/RedirectPurchaseRequest.php
public
mixed
|
|
protected
|
#
createResponse(
Creates the correct type of response for this request. |
protected
string
|
$liveEndpoint,
$testEndpoint
|
$httpClient,
$httpRequest,
$negativeAmountAllowed,
$parameters,
$response,
$zeroAmountAllowed
|