forked from ratepay/php-sdk
-
Notifications
You must be signed in to change notification settings - Fork 0
/
example.paymentConfirm.php
executable file
·41 lines (29 loc) · 1.52 KB
/
example.paymentConfirm.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
<?php
require __DIR__ . '/vendor/autoload.php';
require_once "ratepay_credentials.php";
require_once "helper.createTransaction.php"; // Opens new transaction to handle
/********************************************************
* The PaymentConfirm confirms a authorized transaction *
********************************************************/
// PaymentConfirm needs 'head' only
$mbHead = new RatePAY\ModelBuilder();
$mbHead->setArray([
'SystemId' => "Example",
'Credential' => [
'ProfileId' => PROFILE_ID,
'Securitycode' => SECURITYCODE
],
'TransactionId' => $transactionId,
'External' => [ // If order id or customer id isn't created at the time of Payment Request use Payment Confirm to hand missing information later
'MerchantConsumerId' => "1234567", // Customer Id
'OrderId' => "xyzabc"
]
]);
$rb = new RatePAY\RequestBuilder(true); // Sandbox mode = true
$paymentConfirm = $rb->callPaymentConfirm($mbHead);
if (!$paymentConfirm->isSuccessful()) die("PaymentConfirm not successful");
var_dump("PaymentConfirm successful");
// PaymentConfirm response object provides no specific methods
/*********************************************************************************************************************************
* The library throws decidedly exceptions. It's recommended to surround model building and request calls with try-catch-blocks. *
*********************************************************************************************************************************/