-
Notifications
You must be signed in to change notification settings - Fork 4
/
example.paymentRequest.directDebit.php
executable file
·167 lines (155 loc) · 5.73 KB
/
example.paymentRequest.directDebit.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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
<?php
require __DIR__ . '/vendor/autoload.php';
require_once "ratepay_credentials.php";
/******************************************************
* The PaymentRequest requests authorization of order *
******************************************************/
$mbHead = new RatePAY\ModelBuilder();
$mbHead->setArray([
'SystemId' => "Example",
'Credential' => [
'ProfileId' => PROFILE_ID,
'Securitycode' => SECURITYCODE
]
]);
$rb = new RatePAY\RequestBuilder(true);
$paymentInit = $rb->callPaymentInit($mbHead);
if (!$paymentInit->isSuccessful()) die("PaymentInit not successful");
// Extending head model with required customer device information
$mbHead->setTransactionId($paymentInit->getTransactionId());
$mbHead->setCustomerDevice(
$mbHead->CustomerDevice()->setDeviceToken("1234567890")
);
// External commits additional information about customer and order. Is optional.
$mbHead->setArray([
'External' => [
'MerchantConsumerId' => "1234567", // Customer Id
'OrderId' => "xyzabc"
//'MerchantConsumerClassification' => "X"
//'ShopLanguage' => "DEU"
//'ReferenceId' => "xyzabc"
]
]);
// The PaymentRequest requires a content model.
// Building content model
$mbContent = new RatePAY\ModelBuilder('Content');
$contentArr = [
'Customer' => [
'Gender' => "f",
//'Salutation' => "Mrs.",
//'Title' => "Dr.",
'FirstName' => "Alice",
//'MiddleName' => "J.",
'LastName' => "Nobodyknows",
//'NameSuffix' => "Sen.",
'DateOfBirth' => "1975-12-17",
//'Nationality' => "DE",
//'Language' => "DE",
'IpAddress' => "127.0.0.1",
'Addresses' => [
[
'Address' => [
'Type' => "billing",
'Street' => "Hive Street 12",
//'StreetAdditional' => "SubLevel 27",
//'StreetNumber' => "12",
'ZipCode' => "12345",
'City' => "Raccoon City",
'CountryCode' => "de",
]
], [
'Address' => [
'Type' => "delivery",
//'Salutation' => "Mrs.",
'FirstName' => "Alice",
'LastName' => "Nobodyknows",
//'Company' => "Umbrella Corp.",
'Street' => "Hive Street 12",
//'StreetAdditional' => "SubLevel 27",
//'StreetNumber' => "12",
'ZipCode' => "12345",
'City' => "Raccoon City",
'CountryCode' => "de",
]
]
],
'Contacts' => [
'Email' => "[email protected]",
//'Mobile' => [
//'AreaCode' => "0172",
//'DirectDial' => "0172 3456789"
//],
'Phone' => [
//'AreaCode' => "012",
'DirectDial' => "012 3456789"
],
//'Fax' => [
//'AreaCode' => "012",
//'DirectDial' => "012 3456789"
//],
],
'BankAccount' => [ // In case of payment method 'elv'
'Owner' => "Alice Nobodyknows",
'Iban' => "AT123456789012345678",
//'BankName' => "Umbrella Finance",
//'BankAccountNumber' => "1234567890",
//'BankCode' => "12345678",
],
// 'CompanyName' => "Umbrella Corp.",
// 'CompanyType' => "AG",
// 'VatId' => "DE123456789",
// 'CompanyId' => "HRB 123456X",
// 'RegistryLocation' => "Raccoon City",
// 'Homepage' => "http://www.umbrellacorporation.tld",
],
'ShoppingBasket' => [
'Items' => [
[
'Item' => [
'Description' => "Test product 1",
'ArticleNumber' => "ArtNo1",
//'UniqueArticleNumber' => "ArtNo1-variation123",
'Quantity' => 1,
'UnitPriceGross' => 300,
'TaxRate' => 19,
//'Category' => "Additional information about the product"
//'DescriptionAddition' => "Additional information about the product"
]
], [
'Item' => [
'Description' => "Test product 2",
'ArticleNumber' => "ArtNo2",
'Quantity' => 2,
'UnitPriceGross' => 100,
'TaxRate' => 19,
'Discount' => 10
]
]
],
'Shipping' => [
'Description' => "Shipping costs",
'UnitPriceGross' => 4.95,
'TaxRate' => 19,
//'DescriptionAddition' => "Additional information about the shipping"
],
'Discount' => [
'Description' => "Discount 20 EUR",
'UnitPriceGross' => 20,
'TaxRate' => 19,
//'DescriptionAddition' => "Additional information about the discount"
]
],
'Payment' => [
'Method' => "elv", // "invoice", "installment", "elv", "prepayment"
'Amount' => 464.95
]
];
$mbContent->setArray($contentArr);
$rb = new RatePAY\RequestBuilder(true); // Sandbox mode = true
$paymentRequest = $rb->callPaymentRequest($mbHead, $mbContent);
if (!$paymentRequest->isSuccessful()) die("PaymentRequest not successful");
// The PaymentRequest response object provides following methods:
// getTransactionId(); // Returns transaction id (unique transaction identifier) {string}
// isRetryAdmitted(); // Returns whether retry is admitted {boolean}
// getCustomerMessage(); // Returns customer message {string}
var_dump($paymentRequest->getTransactionId());