How do I complete purchase with Omnipay Sagepay using sagepay server (inframe)

StackOverflow https://stackoverflow.com/questions/21664657

  •  09-10-2022
  •  | 
  •  

I can't seem to find an instructions for Omnipay\SagePay, and am struggling to complete the purchase when SagePay posts to my notification URL.

Can anyone provide info, or point me to where I can find out what actions and parameters are needed for the notification URL to complete the purchase please?

有帮助吗?

解决方案

Sagepay is tricky because the notification part is done by Sagepay and not by the client, so make sure you give an Internet accessible notification URL (that was my first mistake). Here's some example code (using Laravel) to process a Sagepay payment:

public function postProcess($transactionId)
{

    //get the order details from somewhere
    $order = $this->order->findByTransaction($transactionId);

    $response = $this->gateway->completePurchase(array(
        'transactionId' => $order->transaction,
        'transactionReference' => $order->reference,
        'amount' => $order->total,
        'currency' => $order->currency,
    ))->send();

    if ( ! $response->isSuccessful())
    {
        $response->invalid(URL::to('checkout/problem'));
        die();
    }

    $response->confirm(URL::to('checkout/complete/'.$transactionId));

}

As you can see it's quite a bit different from the other examples as you need to call completePurchase() and then separately send a response to confirm.

Let me know if you need anymore help.

Cheers

其他提示

From here you can either read more about the integration methods or scroll to the bottom of the table to download the Server documents. Our kits are available for you to download.

Are you getting an error message when Sage Pay is trying to reach your NotificationURL? Or, are you getting notification that Sage Pay has contacted you via your NotificationURL but you are not able to redirect the shopper to the RedirectionURL, the landing page to tell the shopper about the status of the transaction?

Few points to check for a 5006 error (Unable to redirect to the vendors website. The vendor failed to provide a RedirectionURL).

  • Is the SecurityKey matching?
  • If the transaction is not showing in My Sage Pay, provide Sage Pay with the TxID so that we can check the logs (if within 72 hours)
  • is the NotificationURL an http or https URL? consider html5 issues
  • if Sage Pay can't reach the NotificationURL, check that you have the ports 80 and 443 open. Have you received any attempts to the NotificationURL before?
  • check not a DNS issue
  • check your website is not spooling / not an issue with hosting company?
  • make sure Status=OK rather than Error or Invalid

Can you provide more information so we can help further?

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top