Skip to content

Commit 7a43dd1

Browse files
authored
Merge pull request #23 from PaymentHighway/reference_number_for_single_settlements
Reference number for single settlements
2 parents 36cfe9f + 85444a0 commit 7a43dd1

File tree

6 files changed

+46
-19
lines changed

6 files changed

+46
-19
lines changed

src/FormBuilder.php

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -152,12 +152,14 @@ public function generateAddCardParameters( $acceptCvcRequired = null, $skipFormN
152152
* @param string $webhookCancelUrl The URL the PH server makes request after cancelling the transaction (clicking on the cancel button).
153153
* @param int $webhookDelay Delay for webhook in seconds. Between 0-900
154154
* @param bool $showPaymentMethodSelector
155+
* @param string $referenceNumber Reference number in RF or Finnish reference format, used when settling the transaction to the merchant account. Only used if one-by-ony transaction settling is configured.
156+
*
155157
* @return Form
156158
*/
157159
public function generatePaymentParameters($amount, $currency, $orderId, $description, $skipFormNotifications = null,
158160
$exitIframeOnResult = null, $exitIframeOn3ds = null, $use3ds = null,
159161
$webhookSuccessUrl = null, $webhookFailureUrl = null, $webhookCancelUrl = null,
160-
$webhookDelay = null, $showPaymentMethodSelector = null)
162+
$webhookDelay = null, $showPaymentMethodSelector = null, $referenceNumber = null)
161163

162164
{
163165
$commonParameters = $this->createFormParameterArray();
@@ -176,6 +178,8 @@ public function generatePaymentParameters($amount, $currency, $orderId, $descrip
176178
$commonParameters[self::$SPH_USE_THREE_D_SECURE] = $use3ds;
177179
if(!is_null($showPaymentMethodSelector))
178180
$commonParameters[self::$SPH_SHOW_PAYMENT_METHOD_SELECTOR] = $showPaymentMethodSelector;
181+
if(!is_null($referenceNumber))
182+
$commonParameters[self::$SPH_REFERENCE_NUMBER] = $referenceNumber;
179183

180184
$commonParameters = array_merge($commonParameters,
181185
$this->createWebhookParametersArray($webhookSuccessUrl, $webhookFailureUrl, $webhookCancelUrl, $webhookDelay));
@@ -209,12 +213,13 @@ public function generatePaymentParameters($amount, $currency, $orderId, $descrip
209213
* @param string $webhookFailureUrl The URL the PH server makes request after a failure such as an authentication or connectivity error.
210214
* @param string $webhookCancelUrl The URL the PH server makes request after cancelling the transaction (clicking on the cancel button).
211215
* @param int $webhookDelay Delay for webhook in seconds. Between 0-900
216+
* @param string $referenceNumber Reference number in RF or Finnish reference format, used when settling the transaction to the merchant account. Only used if one-by-ony transaction settling is configured.
212217
* @return Form
213218
*/
214219
public function generateAddCardAndPaymentParameters($amount, $currency, $orderId, $description, $skipFormNotifications = null,
215220
$exitIframeOnResult = null, $exitIframeOn3ds = null, $use3ds = null,
216221
$webhookSuccessUrl = null, $webhookFailureUrl = null, $webhookCancelUrl = null,
217-
$webhookDelay = null)
222+
$webhookDelay = null, $referenceNumber = null)
218223
{
219224
$commonParameters = $this->createFormParameterArray();
220225

@@ -226,6 +231,8 @@ public function generateAddCardAndPaymentParameters($amount, $currency, $orderId
226231
$commonParameters[self::$SPH_EXIT_IFRAME_ON_THREE_D_SECURE] = $exitIframeOn3ds;
227232
if(!is_null($use3ds))
228233
$commonParameters[self::$SPH_USE_THREE_D_SECURE] = $use3ds;
234+
if(!is_null($referenceNumber))
235+
$commonParameters[self::$SPH_REFERENCE_NUMBER] = $referenceNumber;
229236

230237
$commonParameters = array_merge($commonParameters,
231238
$this->createWebhookParametersArray($webhookSuccessUrl, $webhookFailureUrl, $webhookCancelUrl, $webhookDelay));
@@ -261,12 +268,13 @@ public function generateAddCardAndPaymentParameters($amount, $currency, $orderId
261268
* @param string $webhookFailureUrl The URL the PH server makes request after a failure such as an authentication or connectivity error.
262269
* @param string $webhookCancelUrl The URL the PH server makes request after cancelling the transaction (clicking on the cancel button).
263270
* @param int $webhookDelay Delay for webhook in seconds. Between 0-900
271+
* @param string $referenceNumber Reference number in RF or Finnish reference format, used when settling the transaction to the merchant account. Only used if one-by-ony transaction settling is configured.
264272
* @return Form
265273
*/
266274
public function generatePayWithTokenAndCvcParameters( $tokenId, $amount, $currency, $orderId, $description, $skipFormNotifications = null,
267275
$exitIframeOnResult = null, $exitIframeOn3ds = null, $use3ds = null,
268276
$webhookSuccessUrl = null, $webhookFailureUrl = null, $webhookCancelUrl = null,
269-
$webhookDelay = null)
277+
$webhookDelay = null, $referenceNumber = null)
270278
{
271279
$commonParameters = $this->createFormParameterArray();
272280

@@ -278,6 +286,8 @@ public function generatePayWithTokenAndCvcParameters( $tokenId, $amount, $curren
278286
$commonParameters[self::$SPH_EXIT_IFRAME_ON_THREE_D_SECURE] = $exitIframeOn3ds;
279287
if(!is_null($use3ds))
280288
$commonParameters[self::$SPH_USE_THREE_D_SECURE] = $use3ds;
289+
if(!is_null($referenceNumber))
290+
$commonParameters[self::$SPH_REFERENCE_NUMBER] = $referenceNumber;
281291

282292
$commonParameters = array_merge($commonParameters,
283293
$this->createWebhookParametersArray($webhookSuccessUrl, $webhookFailureUrl, $webhookCancelUrl, $webhookDelay));
@@ -314,13 +324,14 @@ public function generatePayWithTokenAndCvcParameters( $tokenId, $amount, $curren
314324
* @param string $webhookFailureUrl The URL the PH server makes request after a failure such as an authentication or connectivity error.
315325
* @param string $webhookCancelUrl The URL the PH server makes request after cancelling the transaction (clicking on the cancel button).
316326
* @param int $webhookDelay Delay for webhook in seconds. Between 0-900
327+
* @param string $referenceNumber Reference number in RF or Finnish reference format, used when settling the transaction to the merchant account. Only used if one-by-ony transaction settling is configured.
317328
* @return Form
318329
*/
319330
public function generatePayWithMobilePayParameters($amount, $currency, $orderId, $description,
320331
$exitIframeOnResult = null, $shopLogoUrl = null, $phoneNumber = null,
321332
$shopName = null , $subMerchantId = null, $subMerchantName = null,
322333
$webhookSuccessUrl = null, $webhookFailureUrl = null, $webhookCancelUrl = null,
323-
$webhookDelay = null)
334+
$webhookDelay = null, $referenceNumber = null)
324335
{
325336
$commonParameters = $this->createFormParameterArray();
326337

@@ -342,6 +353,9 @@ public function generatePayWithMobilePayParameters($amount, $currency, $orderId,
342353
if(!is_null($subMerchantName))
343354
$commonParameters[self::$SPH_SUB_MERCHANT_NAME] = $subMerchantName;
344355

356+
if(!is_null($referenceNumber))
357+
$commonParameters[self::$SPH_REFERENCE_NUMBER] = $referenceNumber;
358+
345359
$commonParameters = array_merge($commonParameters,
346360
$this->createWebhookParametersArray($webhookSuccessUrl, $webhookFailureUrl, $webhookCancelUrl, $webhookDelay));
347361

@@ -377,12 +391,13 @@ public function generatePayWithMobilePayParameters($amount, $currency, $orderId,
377391
* @param string $webhookFailureUrl The URL the PH server makes request after a failure such as an authentication or connectivity error.
378392
* @param string $webhookCancelUrl The URL the PH server makes request after cancelling the transaction (clicking on the cancel button).
379393
* @param int $webhookDelay Delay for webhook in seconds. Between 0-900
394+
* @param string $referenceNumber Reference number in RF or Finnish reference format, used when settling the transaction to the merchant account. Only used if one-by-ony transaction settling is configured.
380395
* @return Form
381396
*/
382397
public function generateMasterpassParameters($amount, $currency, $orderId, $description, $skipFormNotifications = null,
383398
$exitIframeOnResult = null, $exitIframeOn3ds = null, $use3ds = null,
384399
$webhookSuccessUrl = null, $webhookFailureUrl = null, $webhookCancelUrl = null,
385-
$webhookDelay = null)
400+
$webhookDelay = null, $referenceNumber = null)
386401
{
387402
$commonParameters = $this->createFormParameterArray();
388403

@@ -398,6 +413,8 @@ public function generateMasterpassParameters($amount, $currency, $orderId, $desc
398413
$commonParameters[self::$SPH_EXIT_IFRAME_ON_THREE_D_SECURE] = $exitIframeOn3ds;
399414
if(!is_null($use3ds))
400415
$commonParameters[self::$SPH_USE_THREE_D_SECURE] = $use3ds;
416+
if(!is_null($referenceNumber))
417+
$commonParameters[self::$SPH_REFERENCE_NUMBER] = $referenceNumber;
401418

402419
$commonParameters = array_merge($commonParameters,
403420
$this->createWebhookParametersArray($webhookSuccessUrl, $webhookFailureUrl, $webhookCancelUrl, $webhookDelay));

src/Model/Request/CustomerInitiatedTransaction.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ class CustomerInitiatedTransaction extends \Solinor\PaymentHighway\Model\JsonSer
2323

2424
public $commit = null;
2525

26+
public $reference_number = null;
27+
2628
/**
2729
* @param Card|Token|null $request
2830
* @param int $amount
@@ -32,9 +34,10 @@ class CustomerInitiatedTransaction extends \Solinor\PaymentHighway\Model\JsonSer
3234
* @param string $orderId
3335
* @param \Solinor\PaymentHighway\Model\Splitting $splitting
3436
* @param bool $commit Whether or not automatically commit the payment. Default true.
37+
* @param string $referenceNumber Reference number in RF or Finnish reference format, used when settling the transaction to the merchant account. Only used if one-by-ony transaction settling is configured.
3538
* @throws \Exception
3639
*/
37-
public function __construct( $request, $amount, $currency, $strong_customer_authentication, $blocking = true, $orderId = null, $splitting = null, $commit = true)
40+
public function __construct( $request, $amount, $currency, $strong_customer_authentication, $blocking = true, $orderId = null, $splitting = null, $commit = true, $referenceNumber = null)
3841
{
3942
$this->amount = $amount;
4043
$this->currency = $currency;
@@ -43,6 +46,7 @@ public function __construct( $request, $amount, $currency, $strong_customer_auth
4346
$this->splitting = $splitting;
4447
$this->strong_customer_authentication = $strong_customer_authentication;
4548
$this->commit = $commit;
49+
$this->reference_number = $referenceNumber;
4650

4751
$this->setRequestByType($request);
4852
}

src/Model/Request/Transaction.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ class Transaction extends \Solinor\PaymentHighway\Model\JsonSerializable
2020
public $splitting = null;
2121
public $commit = null;
2222

23+
public $reference_number = null;
24+
2325
/**
2426
* @param int $amount
2527
* @param string $currency
@@ -28,16 +30,18 @@ class Transaction extends \Solinor\PaymentHighway\Model\JsonSerializable
2830
* @param string $orderId
2931
* @param \Solinor\PaymentHighway\Model\Splitting $splitting
3032
* @param bool $commit Whether or not automatically commit the payment. Default true.
33+
* @param string $referenceNumber Reference number in RF or Finnish reference format, used when settling the transaction to the merchant account. Only used if one-by-ony transaction settling is configured.
3134
* @throws \Exception
3235
*/
33-
public function __construct( $request, $amount, $currency, $blocking = true, $orderId = null, $splitting = null, $commit = null)
36+
public function __construct( $request, $amount, $currency, $blocking = true, $orderId = null, $splitting = null, $commit = null, $referenceNumber = null)
3437
{
3538
$this->amount = $amount;
3639
$this->currency = $currency;
3740
$this->order = $orderId;
3841
$this->blocking = $blocking;
3942
$this->splitting = $splitting;
4043
$this->commit = $commit;
44+
$this->reference_number = $referenceNumber;
4145

4246
$this->setRequestByType($request);
4347
}

src/PaymentApi.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ class PaymentApi
5656
* @param string $merchant
5757
* @param string $apiversion
5858
*/
59-
public function __construct($serviceUrl, $signatureKeyId, $signatureSecret, $account, $merchant, $apiversion = "20180725")
59+
public function __construct($serviceUrl, $signatureKeyId, $signatureSecret, $account, $merchant, $apiversion = "20191204")
6060
{
6161
$this->serviceUrl = $serviceUrl;
6262
$this->signatureKeyId = $signatureKeyId;

tests/unit/FormBuilderTest.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,19 +41,21 @@ public function PaymentParameters($method, $signatureKeyId, $signatureSecret, $a
4141
$showPaymentSelector
4242
)
4343
{
44+
$referenceNumber = "1313";
45+
4446
$formbuilder = new \Solinor\PaymentHighway\FormBuilder(
4547
$method, $signatureKeyId, $signatureSecret, $account,
4648
$merchant, $baseUrl, $successUrl, $failureUrl,
4749
$cancelUrl, $language
4850
);
4951

5052
$form = $formbuilder->generatePaymentParameters($amount, $currency, $orderId, $description, null,
51-
null, null, null, $showPaymentSelector);
53+
null, null, null, $showPaymentSelector, $referenceNumber);
5254

5355
$this->assertInstanceOf('\Solinor\PaymentHighway\Model\Form', $form);
5456
$this->assertEquals($baseUrl . '/form/view/pay_with_card', $form->getAction());
5557
$this->assertEquals($method, $form->getMethod());
56-
$this->assertCount(14, $form->getParameters());
58+
$this->assertCount(15, $form->getParameters());
5759
}
5860

5961
/**

tests/unit/PaymentApiTest.php

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,8 @@ class PaymentApiTest extends TestBase
4545
const InvalidPan = '415301399900024';
4646
const InvalidCvc = '022';
4747

48+
const TestReferenceNumber = "1313";
49+
4850
protected static $orderId;
4951

5052
/**
@@ -98,7 +100,7 @@ public function initHandlerSuccessfully( PaymentApi $api )
98100
public function debitTransactionSuccess(PaymentApi $api, $transactionId )
99101
{
100102

101-
$card = $this->getValidCardTransactionRequest();
103+
$card = $this->getValidCardTransactionRequest(null, self::TestReferenceNumber);
102104

103105
$response = $api->debitTransaction( $transactionId, $card)->body;
104106

@@ -116,13 +118,8 @@ public function debitTransactionSuccess(PaymentApi $api, $transactionId )
116118
* @param string $transactionId
117119
* @return string transactionId
118120
*/
119-
public function transactionStatus(PaymentApi $api, $transactionId )
121+
public function transactionResult(PaymentApi $api, $transactionId )
120122
{
121-
122-
$card = $this->getValidCardTransactionRequest();
123-
124-
$api->debitTransaction( $transactionId, $card)->body;
125-
126123
$response = $api->transactionResult( $transactionId)->body;
127124

128125
$this->assertEquals('100', $response->result->code);
@@ -162,6 +159,7 @@ public function transactionStatusAfterDebit(PaymentApi $api, $transactionId)
162159
$response = $api->statusTransaction($transactionId)->body;
163160

164161
$this->assertEquals('4000', $response->transaction->status->code);
162+
$this->assertEquals(self::TestReferenceNumber, $response->transaction->reference_number);
165163
$this->assertEquals('100', $response->result->code);
166164
$this->assertEquals('OK', $response->result->message);
167165
}
@@ -336,7 +334,7 @@ public function splittingDetailsAreReturnedInTransactionStatus(PaymentApi $api)
336334
* @param Splitting $splitting
337335
* @return Transaction
338336
*/
339-
private function getValidCardTransactionRequest($splitting = null)
337+
private function getValidCardTransactionRequest($splitting = null, $referenceNumber = null)
340338
{
341339
return new Transaction(
342340
new Card(
@@ -349,7 +347,9 @@ private function getValidCardTransactionRequest($splitting = null)
349347
'EUR',
350348
true,
351349
self::$orderId,
352-
$splitting
350+
$splitting,
351+
true,
352+
$referenceNumber
353353
);
354354
}
355355

0 commit comments

Comments
 (0)