Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions example/transactions/in3-abn-amro-achteraf-betalen.php
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,14 @@
//Pay - Using In3 with Route parameter for ABN AMRO Achteraf Betalen
$response = $buckaroo->method('in3')->pay($payload);

//Authorize - ABN AMRO "Zakelijk op rekening" requires the separate Authorize/Capture flow
$response = $buckaroo->method('in3')->authorize($payload);

//Capture - capture a previously authorized ABN AMRO "Zakelijk op rekening" transaction
$response = $buckaroo->method('in3')->capture($payload + [
'originalTransactionKey' => '9AA4C81A08A84FA7B68E6A6A6291XXXX',
]);

//Refund
$response = $buckaroo->method('in3')->refund([
'amountCredit' => 10,
Expand Down
28 changes: 28 additions & 0 deletions src/PaymentMethods/In3/In3.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,32 @@ public function pay(?Model $model = null): TransactionResponse
{
return parent::pay($model ?? new Pay($this->payload));
}

/**
* @return TransactionResponse
*/
public function authorize(): TransactionResponse
{
$pay = new Pay($this->payload);

$this->setPayPayload();

$this->setServiceList('Authorize', $pay);

return $this->postRequest();
}

/**
* @return TransactionResponse
*/
public function capture(): TransactionResponse
{
$pay = new Pay($this->payload);

$this->setPayPayload();

$this->setServiceList('Capture', $pay);

return $this->postRequest();
}
}
88 changes: 88 additions & 0 deletions tests/Feature/PaymentMethods/In3Test.php
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,94 @@ public function it_pays_remainder_amount(): void
$this->assertTrue($response->get('IsTest'));
}

/** @test */
public function it_creates_authorize_transaction(): void
{
$transactionKey = TestHelpers::generateTransactionKey();

$this->mockBuckaroo->mockTransportRequests([
BuckarooMockRequest::json('POST', '*/json/Transaction*', [
'Key' => $transactionKey,
'Status' => [
'Code' => ['Code' => 190, 'Description' => 'Success'],
'SubCode' => ['Code' => 'S001', 'Description' => 'Authorization successful'],
'DateTime' => date('Y-m-d\TH:i:s'),
],
'RequiredAction' => null,
'Services' => [
[
'Name' => 'in3',
'Action' => 'Authorize',
'Parameters' => [],
],
],
'Invoice' => 'INV-IN3-AUTH-001',
'Currency' => 'EUR',
'AmountDebit' => 250.00,
'IsTest' => true,
]),
]);

$response = $this->buckaroo->method('in3')->authorize([
'amountDebit' => 250.00,
'invoice' => 'INV-IN3-AUTH-001',
'currency' => 'EUR',
'route' => 'abn_b2b',
]);

$this->assertTrue($response->isSuccess());
$this->assertEquals($transactionKey, $response->getTransactionKey());
$this->assertEquals('INV-IN3-AUTH-001', $response->getInvoice());
$this->assertEquals('EUR', $response->getCurrency());
$this->assertEquals(250.00, $response->getAmountDebit());
$this->assertTrue($response->get('IsTest'));
}

/** @test */
public function it_captures_authorized_payment(): void
{
$transactionKey = TestHelpers::generateTransactionKey();
$originalTxKey = 'ORIG_IN3_AUTH_TX_KEY';

$this->mockBuckaroo->mockTransportRequests([
BuckarooMockRequest::json('POST', '*/json/Transaction*', [
'Key' => $transactionKey,
'Status' => [
'Code' => ['Code' => 190, 'Description' => 'Success'],
'SubCode' => ['Code' => 'S001', 'Description' => 'Capture successful'],
'DateTime' => date('Y-m-d\TH:i:s'),
],
'RequiredAction' => null,
'Services' => [
[
'Name' => 'in3',
'Action' => 'Capture',
'Parameters' => [],
],
],
'Invoice' => 'INV-IN3-CAPTURE-001',
'Currency' => 'EUR',
'AmountDebit' => 250.00,
'IsTest' => true,
]),
]);

$response = $this->buckaroo->method('in3')->capture([
'amountDebit' => 250.00,
'invoice' => 'INV-IN3-CAPTURE-001',
'currency' => 'EUR',
'route' => 'abn_b2b',
'originalTransactionKey' => $originalTxKey,
]);

$this->assertTrue($response->isSuccess());
$this->assertEquals($transactionKey, $response->getTransactionKey());
$this->assertEquals('INV-IN3-CAPTURE-001', $response->getInvoice());
$this->assertEquals('EUR', $response->getCurrency());
$this->assertEquals(250.00, $response->getAmountDebit());
$this->assertTrue($response->get('IsTest'));
}

/** @test */
public function it_refunds_payment(): void
{
Expand Down
Loading