-
Notifications
You must be signed in to change notification settings - Fork 4
/
example.paymentChange.changeOrder.php
executable file
·60 lines (47 loc) · 2.08 KB
/
example.paymentChange.changeOrder.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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
<?php
require __DIR__ . '/vendor/autoload.php';
require_once "ratepay_credentials.php";
require_once "helper.createTransaction.php"; // Opens new transaction to handle
require_once "helper.deliverTransaction.php"; // Delivers transaction to handle
/*************************************************************************
* The PaymentChange alters order details (shopping basket) *
* The subtype Change Order changes the whole content of shopping basket *
*************************************************************************/
$mbHead = new RatePAY\ModelBuilder('head');
$mbHead->setArray([
'SystemId' => "Example",
'Credential' => [
'ProfileId' => PROFILE_ID,
'Securitycode' => SECURITYCODE
],
'TransactionId' => $transactionId
]);
/*
* The PaymentChange Change Order (PCh) requires all articles of an changed order.
* It has to be send after the ConfirmationDeliver
*/
$shoppingBasket = [
'ShoppingBasket' => [
'Items' => [
[
'Item' => [
'Description' => "Different Test product X",
'ArticleNumber' => "X.123",
'Quantity' => 2,
'UnitPriceGross' => 219.95,
'TaxRate' => 19,
]
]
]
]
];
$mbContent = new RatePAY\ModelBuilder('Content');
$mbContent->setArray($shoppingBasket);
// PaymentChange has to be specified by subtype
$pChChangeOrder = $rb->callPaymentChange($mbHead, $mbContent)->subtype('change-order');
if (!$pChChangeOrder->isSuccessful()) die("PaymentChange not successful");
var_dump("PaymentChange successful");
// PaymentChange 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. *
*********************************************************************************************************************************/