Skip to content
This repository has been archived by the owner on Oct 10, 2024. It is now read-only.

Commit

Permalink
Merge pull request #2 from lunar/feature/add-update-preffered-method
Browse files Browse the repository at this point in the history
Feature/add update preffered method
  • Loading branch information
ionutcalaralunar authored Feb 16, 2024
2 parents 36436f5 + b6fa7ae commit 58cf2d1
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 1 deletion.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "lunar/payments-api-sdk",
"description": "PHP SDK to communicate with the Lunar HTTP API",
"version": "1.0.0",
"version": "1.0.1",
"license": "MIT",
"minimum-stability": "dev",
"autoload": {
Expand Down
18 changes: 18 additions & 0 deletions src/Endpoint/Payments.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,24 @@ public function intent($payment_id)
return $api_response->json;
}

/**
*
* @param $payment_id
* @param $method
*
* @return array
*/
public function updatePreferredPaymentMethod($payment_id, $method)
{
$url = 'payments/' . $payment_id.'/intent/preferredPaymentMethod';

$api_response = $this->lunar->client->request('POST', $url, [
'preferredPaymentMethod' => $method
]);

return $api_response->json;
}

public function submit($payment_id, $args)
{
$url = 'payments/' . $payment_id.'/submit';
Expand Down
15 changes: 15 additions & 0 deletions tests/PaymentsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,21 @@ public function testUpdatePaymentMethod()
$this->assertEquals('mobilePay', $payment['selectedPaymentMethod']);
}

public function testUpdatePreferred()
{
$response = $this->payments->updatePreferredPaymentMethod($this->payment_id,'card');

$payment = $this->payments->fetch($this->payment_id);

$this->assertEquals('card', $payment['preferredPaymentMethod']);

$response = $this->payments->updatePreferredPaymentMethod($this->payment_id,'mobilePay');

$payment = $this->payments->fetch($this->payment_id);

$this->assertEquals('mobilePay', $payment['preferredPaymentMethod']);
}

public function testIntent()
{

Expand Down

0 comments on commit 58cf2d1

Please sign in to comment.