Skip to content

Complete Purchase (Ödemeyi Tamamla)

Tolga Can Günel edited this page Sep 11, 2021 · 3 revisions

Create Paytr Gateway, set your merchant id, key and salt. You can get them from your Paytr panel.

Build your options, send with the method. getData method will return an object with all possible values.

This method will be used in your callback url page. Callback URL is set on your Paytr panel.

If everything goes well, getMessage() method will return "OK" and Paytr will process the amount from customer to you.

DO NOT PRINT ANYTHING ELSE OTHER THAN $response->getMessage() ON THIS PAGE.

$gateway = \Omnipay\Omnipay::create("Paytr");

$gateway->setMerchantId("000000");

$gateway->setMerchantKey("--------------");

$gateway->setMerchantSalt("---------------");

$gateway->setTestMode(true);

/** @var \Omnipay\Paytr\Message\CompletePurchaseRequest $request */
$request = $gateway->completePurchase();

$request->setToken($post["hash"]);
$request->setTransactionId($post["merchant_oid"]);
$request->setStatus($post["status"]);
$request->setAmountInteger($post["payment_amount"]);
$request->setTotalAmount($post["total_amount"]);
$request->setTestMode($post["test_mode"]);
$request->setPaymentType($post["payment_type"]);
$request->setCurrency($post["currency"]);
$request->setFailCode($post["failed_reason_code"]);
$request->setFailReason($post["failed_reason_msg"]);

/** @var \Omnipay\Paytr\Message\CompletePurchaseResponse $response */
$response = $request->send();

echo $response->getMessage();