Skip to content

Commit

Permalink
Merge pull request thephpleague#178 from aimeoscom/master
Browse files Browse the repository at this point in the history
Adds methods for required settings to do token based payments
  • Loading branch information
barryvdh authored May 25, 2020
2 parents 1b27d76 + a9c9399 commit 37266c2
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 2 deletions.
53 changes: 51 additions & 2 deletions src/Message/PaymentIntents/AuthorizeRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -110,10 +110,11 @@ class AuthorizeRequest extends AbstractRequest
* Set the confirm parameter.
*
* @param $value
* @return AbstractRequest provides a fluent interface.
*/
public function setConfirm($value)
{
$this->setParameter('confirm', $value);
return $this->setParameter('confirm', $value);
}

/**
Expand Down Expand Up @@ -286,6 +287,48 @@ public function setReceiptEmail($email)
return $this;
}

/**
* Set the setup_future_usage parameter.
*
* @param $value
* @return AbstractRequest provides a fluent interface.
*/
public function setSetupFutureUsage($value)
{
return $this->setParameter('setup_future_usage', $value);
}

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

/**
* Set the setup_future_usage parameter.
*
* @param $value
* @return AbstractRequest provides a fluent interface.
*/
public function setOffSession($value)
{
return $this->setParameter('off_session', $value);
}

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

/**
* @inheritdoc
*/
Expand Down Expand Up @@ -343,12 +386,18 @@ public function getData()
$data['customer'] = $this->getCustomerReference();
}

if ($this->getSetupFutureUsage()) {
$data['setup_future_usage'] = $this->getSetupFutureUsage();
}

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

$data['confirmation_method'] = 'manual';
$data['capture_method'] = 'manual';

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

if ($this->getConfirm()) {
if ($this->getConfirm() && !$this->getOffSession()) {
$this->validate('returnUrl');
$data['return_url'] = $this->getReturnUrl();
}
Expand Down
4 changes: 4 additions & 0 deletions tests/Message/PaymentIntents/AuthorizeRequestTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ public function setUp()
),
'applicationFee' => '1.00',
'returnUrl' => 'complete-payment',
'setup_future_usage' => 'off_session',
'off_session' => false,
'confirm' => true,
)
);
Expand All @@ -42,6 +44,8 @@ public function testGetData()
$this->assertSame('pm_valid_payment_method', $data['payment_method']);
$this->assertSame(array('foo' => 'bar'), $data['metadata']);
$this->assertSame(100, $data['application_fee']);
$this->assertSame('off_session', $data['setup_future_usage']);
$this->assertSame('false', $data['off_session']);
}

/**
Expand Down

0 comments on commit 37266c2

Please sign in to comment.