Skip to content
Open
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
57 changes: 52 additions & 5 deletions src/Message/PaymentIntents/AuthorizeRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -328,6 +328,56 @@ public function getOffSession()
{
return $this->getParameter('off_session');
}

/**
* Set the capture method, accepts automatic or manual
*
* @param string $value
*
* @return AbstractRequest provides a fluent interface.
*/
public function setCaptureMethod($value)
{
$value = ($value === null) ? 'automatic' : $value;

return $this->setParameter('capture_method', $value);
}


/**
* Get the capture_method parameter.
*
* @return mixed
*/
public function getCaptureMethod()
{
return $this->getParameter('capture_method');
}

/**
* Set the confirmation method, accepts automatic or manual
*
* @param string $value
*
* @return AbstractRequest provides a fluent interface.
*/
public function setConfirmationMethod($value)
{
$value = ($value === null) ? 'automatic' : $value;

return $this->setParameter('confirmation_method', $value);
}


/**
* Get the confrimation_method parameter.
*
* @return mixed
*/
public function getConfirmationMethod()
{
return $this->getParameter('confirmation_method');
}

/**
* @inheritdoc
Expand Down Expand Up @@ -377,9 +427,6 @@ public function getData()
'type' => 'card',
'card' => ['token' => $this->getToken()],
];
} else {
// one of cardReference, token, or card is required
$this->validate('paymentMethod');
}

if ($this->getCustomerReference()) {
Expand All @@ -392,8 +439,8 @@ public function getData()

$data['off_session'] = $this->getOffSession() ? 'true' : 'false';

$data['confirmation_method'] = 'manual';
$data['capture_method'] = 'manual';
$data['confirmation_method'] = $this->getConfirmationMethod();
$data['capture_method'] = $this->getCaptureMethod();

$data['confirm'] = $this->getConfirm() ? 'true' : 'false';

Expand Down
6 changes: 4 additions & 2 deletions tests/Message/PaymentIntents/AuthorizeRequestTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ public function setUp()
'setup_future_usage' => 'off_session',
'off_session' => false,
'confirm' => true,
'capture_method' => null,
'confirmation_method' => null
)
);
}
Expand All @@ -39,8 +41,8 @@ public function testGetData()
$this->assertSame(1200, $data['amount']);
$this->assertSame('usd', $data['currency']);
$this->assertSame('Order #42', $data['description']);
$this->assertSame('manual', $data['capture_method']);
$this->assertSame('manual', $data['confirmation_method']);
$this->assertSame('automatic', $data['capture_method']);
$this->assertSame('automatic', $data['confirmation_method']);
$this->assertSame('pm_valid_payment_method', $data['payment_method']);
$this->assertSame(array('foo' => 'bar'), $data['metadata']);
$this->assertSame(100, $data['application_fee']);
Expand Down
6 changes: 4 additions & 2 deletions tests/Message/PaymentIntents/PurchaseRequestTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@ public function setUp()
'metadata' => array(
'foo' => 'bar',
),
'applicationFee' => '1.00'
'applicationFee' => '1.00',
'capture_method' => null,
'confirmation_method' => null
)
);
}
Expand All @@ -36,7 +38,7 @@ public function testGetData()
$this->assertSame('usd', $data['currency']);
$this->assertSame('Order #42', $data['description']);
$this->assertSame('automatic', $data['capture_method']);
$this->assertSame('manual', $data['confirmation_method']);
$this->assertSame('automatic', $data['confirmation_method']);
$this->assertSame('pm_valid_payment_method', $data['payment_method']);
$this->assertSame(array('foo' => 'bar'), $data['metadata']);
$this->assertSame(100, $data['application_fee']);
Expand Down