Overview

Namespaces

  • Guzzle
    • Batch
      • Exception
    • Cache
    • Common
      • Exception
    • Http
      • Curl
      • Exception
      • Message
        • Header
      • QueryAggregator
    • Inflection
    • Iterator
    • Log
    • Parser
      • Cookie
      • Message
      • UriTemplate
      • Url
    • Plugin
      • Async
      • Backoff
      • Cache
      • Cookie
        • CookieJar
        • Exception
      • CurlAuth
      • ErrorResponse
        • Exception
      • History
      • Log
      • Md5
      • Mock
      • Oauth
    • Service
      • Builder
      • Command
        • Factory
        • LocationVisitor
          • Request
          • Response
      • Description
      • Exception
      • Resource
    • Stream
    • Tests
      • Batch
      • Cache
      • Common
        • Cache
        • Exception
      • Http
        • Curl
        • Exception
        • Message
          • Header
      • Inflection
      • Iterator
      • Log
      • Message
      • Mock
      • Parser
        • Cookie
        • Message
      • Parsers
        • UriTemplate
      • Plugin
        • Async
        • Backoff
        • Cache
        • Cookie
          • CookieJar
        • CurlAuth
        • ErrorResponse
        • History
        • Log
        • Md5
        • Mock
        • Oauth
        • Redirect
      • Service
        • Builder
        • Command
          • LocationVisitor
            • Request
            • Response
        • Description
        • Exception
        • Mock
          • Command
            • Sub
          • Model
        • Resource
      • Stream
  • None
  • Omnipay
    • Common
      • Exception
      • Message
    • Dummy
      • Message
    • VivaPayments
      • Message
  • PHP

Classes

  • AbstractRestRequest
  • FetchTransactionsRequest
  • NativeAuthorizeRequest
  • NativePurchaseRequest
  • RedirectAuthorizeRequest
  • RedirectPurchaseRequest
  • RedirectResponse
  • RefundRequest
  • RestResponse
  • Overview
  • Namespace
  • Class
  • Tree

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
Extended by Omnipay\VivaPayments\Message\AbstractRestRequest
Extended by Omnipay\VivaPayments\Message\RedirectPurchaseRequest

Direct known subclasses

Omnipay\VivaPayments\Message\RedirectAuthorizeRequest
Namespace: Omnipay\VivaPayments\Message
See: 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
Methods summary
public mixed
# getData( )

Get the raw data array for this message. The format of this varies from gateway to gateway, but will usually be either an associative array, or a SimpleXMLElement.

Get the raw data array for this message. The format of this varies from gateway to gateway, but will usually be either an associative array, or a SimpleXMLElement.

Returns

mixed

Overrides

Omnipay\VivaPayments\Message\AbstractRestRequest::getData()
protected Omnipay\VivaPayments\Message\RestResponse
# createResponse( Omnipay\Common\Message\RequestInterface $request, $data, integer $statusCode = 200 )

Creates the correct type of response for this request.

Creates the correct type of response for this request.

This is a hook to allow different types of request to create their own response types, normally used when there is a redirect request of some kind.

Parameters

$request
$data
$statusCode

Returns

Omnipay\VivaPayments\Message\RestResponse

Overrides

Omnipay\VivaPayments\Message\AbstractRestRequest::createResponse()
protected string
# getEndpoint( )

Get transaction endpoint.

Get transaction endpoint.

Purchases are created using the /purchases resource.

Returns

string

Overrides

Omnipay\VivaPayments\Message\AbstractRestRequest::getEndpoint()
Methods inherited from Omnipay\VivaPayments\Message\AbstractRestRequest
getApiKey(), getBaseEndpoint(), getHttpMethod(), getMerchantId(), getRequestLang(), getSourceCode(), sendData(), setApiKey(), setMerchantId(), setRequestLang(), setSourceCode()
Methods inherited from Omnipay\Common\Message\AbstractRequest
__construct(), formatCurrency(), getAmount(), getAmountInteger(), getCancelUrl(), getCard(), getCardReference(), getClientIp(), getCurrency(), getCurrencyDecimalPlaces(), getCurrencyNumeric(), getDescription(), getIssuer(), getItems(), getNotifyUrl(), getParameter(), getParameters(), getPaymentMethod(), getResponse(), getReturnUrl(), getTestMode(), getToken(), getTransactionId(), getTransactionReference(), initialize(), send(), setAmount(), setCancelUrl(), setCard(), setCardReference(), setClientIp(), setCurrency(), setDescription(), setIssuer(), setItems(), setNotifyUrl(), setParameter(), setPaymentMethod(), setReturnUrl(), setTestMode(), setToken(), setTransactionId(), setTransactionReference(), toFloat(), validate()
Properties inherited from Omnipay\VivaPayments\Message\AbstractRestRequest
$liveEndpoint, $testEndpoint
Properties inherited from Omnipay\Common\Message\AbstractRequest
$httpClient, $httpRequest, $negativeAmountAllowed, $parameters, $response, $zeroAmountAllowed
Omnipay Viva Payments Gateway Module API Documentation API documentation generated by ApiGen