-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for paymaya payment intent attach. (#44)
* Add support for paymaya payment intent attach. * Apply fixes from StyleCI Co-authored-by: Rigel Kent Carbonel <[email protected]>
- Loading branch information
Showing
5 changed files
with
109 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
C:37:"PHPUnit\Runner\DefaultTestResultCache":3601:{a:2:{s:7:"defects";a:10:{s:56:"Luigel\Paymongo\Tests\PaymentTest::it_can_create_payment";i:4;s:93:"Luigel\Paymongo\Tests\PaymentTest::it_cannot_create_payment_when_token_is_used_more_than_once";i:3;s:83:"Luigel\Paymongo\Tests\PaymentTest::it_cannot_create_payment_when_token_is_not_valid";i:4;s:60:"Luigel\Paymongo\Tests\PaymentTest::it_can_retrieve_a_payment";i:4;s:80:"Luigel\Paymongo\Tests\PaymentTest::it_can_not_retrieve_a_payment_with_invalid_id";i:3;s:58:"Luigel\Paymongo\Tests\PaymentTest::it_can_get_all_payments";i:4;s:54:"Luigel\Paymongo\Tests\TokenTest::it_can_retrieve_token";i:4;s:88:"Luigel\Paymongo\Tests\PaymongoValidateSignatureTest::it_will_not_allow_invalid_signature";i:3;s:82:"Luigel\Paymongo\Tests\PaymongoValidateSignatureTest::it_will_allow_valid_signature";i:5;s:52:"Luigel\Paymongo\Tests\BaseModelTest::it_can_set_data";i:4;}s:5:"times";a:31:{s:69:"Luigel\Paymongo\Tests\PaymentIntentTest::it_can_create_payment_intent";d:0.543;s:93:"Luigel\Paymongo\Tests\PaymentIntentTest::it_cannot_create_payment_intent_when_data_is_invalid";d:0.426;s:69:"Luigel\Paymongo\Tests\PaymentIntentTest::it_can_cancel_payment_intent";d:0.861;s:87:"Luigel\Paymongo\Tests\PaymentIntentTest::it_can_attach_payment_method_to_payment_intent";d:1.744;s:90:"Luigel\Paymongo\Tests\PaymentIntentTest::it_cannot_attach_payment_intent_with_invalid_data";d:0.444;s:71:"Luigel\Paymongo\Tests\PaymentIntentTest::it_can_retrieve_payment_intent";d:0.945;s:69:"Luigel\Paymongo\Tests\PaymentMethodTest::it_can_create_payment_method";d:0.544;s:90:"Luigel\Paymongo\Tests\PaymentMethodTest::it_cannot_create_payment_method_with_invalid_data";d:0.539;s:71:"Luigel\Paymongo\Tests\PaymentMethodTest::it_can_retrieve_payment_method";d:1.019;s:56:"Luigel\Paymongo\Tests\PaymentTest::it_can_create_payment";d:1.41;s:93:"Luigel\Paymongo\Tests\PaymentTest::it_cannot_create_payment_when_token_is_used_more_than_once";d:6.54;s:83:"Luigel\Paymongo\Tests\PaymentTest::it_cannot_create_payment_when_token_is_not_valid";d:1.581;s:60:"Luigel\Paymongo\Tests\PaymentTest::it_can_retrieve_a_payment";d:1.617;s:80:"Luigel\Paymongo\Tests\PaymentTest::it_can_not_retrieve_a_payment_with_invalid_id";d:0.989;s:58:"Luigel\Paymongo\Tests\PaymentTest::it_can_get_all_payments";d:1.1;s:62:"Luigel\Paymongo\Tests\SourceTest::it_can_create_a_gcash_source";d:0.426;s:65:"Luigel\Paymongo\Tests\SourceTest::it_can_create_a_grab_pay_source";d:0.442;s:54:"Luigel\Paymongo\Tests\TokenTest::it_can_retrieve_token";d:0.896;s:59:"Luigel\Paymongo\Tests\WebhookTest::it_can_list_all_webhooks";d:0.406;s:58:"Luigel\Paymongo\Tests\WebhookTest::it_can_retrieve_webhook";d:0.798;s:58:"Luigel\Paymongo\Tests\WebhookTest::it_can_create_a_webhook";d:1.378;s:68:"Luigel\Paymongo\Tests\WebhookTest::it_can_disable_and_enable_webhook";d:2.322;s:52:"Luigel\Paymongo\Tests\TokenTest::it_can_create_token";d:0.574;s:73:"Luigel\Paymongo\Tests\TokenTest::it_cannot_create_token_with_invalid_data";d:0.456;s:95:"Luigel\Paymongo\Tests\UnauthorizedTest::it_expects_unauthorized_exception_with_invalid_api_keys";d:0.445;s:88:"Luigel\Paymongo\Tests\PaymongoValidateSignatureTest::it_will_not_allow_invalid_signature";d:0.008;s:82:"Luigel\Paymongo\Tests\PaymongoValidateSignatureTest::it_will_allow_valid_signature";d:0.005;s:52:"Luigel\Paymongo\Tests\BaseModelTest::it_can_set_data";d:0.002;s:72:"Luigel\Paymongo\Tests\AmounToIntegerTest::it_can_convert_without_decimal";d:0.049;s:78:"Luigel\Paymongo\Tests\AmounToIntegerTest::it_can_convert_with_in_tenth_decimal";d:0.001;s:82:"Luigel\Paymongo\Tests\AmounToIntegerTest::it_can_convert_with_in_hundredth_decimal";d:0.001;}}} | ||
{"version":1,"defects":{"Luigel\\Paymongo\\Tests\\PaymentIntentTest::it_can_attach_paymaya_payment_method_to_payment_intent":4},"times":{"Luigel\\Paymongo\\Tests\\AmounToIntegerTest::it_can_convert_without_decimal":0.052,"Luigel\\Paymongo\\Tests\\AmounToIntegerTest::it_can_convert_with_in_tenth_decimal":0.002,"Luigel\\Paymongo\\Tests\\AmounToIntegerTest::it_can_convert_with_in_hundredth_decimal":0.001,"Luigel\\Paymongo\\Tests\\BaseModelTest::it_can_set_data":0.002,"Luigel\\Paymongo\\Tests\\PaymentIntentTest::it_can_create_payment_intent":0.549,"Luigel\\Paymongo\\Tests\\PaymentIntentTest::it_cannot_create_payment_intent_when_data_is_invalid":0.388,"Luigel\\Paymongo\\Tests\\PaymentIntentTest::it_can_cancel_payment_intent":0.83,"Luigel\\Paymongo\\Tests\\PaymentIntentTest::it_can_attach_payment_method_to_payment_intent":1.62,"Luigel\\Paymongo\\Tests\\PaymentIntentTest::it_cannot_attach_payment_intent_with_invalid_data":0.402,"Luigel\\Paymongo\\Tests\\PaymentIntentTest::it_can_retrieve_payment_intent":0.829,"Luigel\\Paymongo\\Tests\\PaymentMethodTest::it_can_create_payment_method":0.484,"Luigel\\Paymongo\\Tests\\PaymentMethodTest::it_cannot_create_payment_method_with_invalid_data":0.41,"Luigel\\Paymongo\\Tests\\PaymentMethodTest::it_can_retrieve_payment_method":0.924,"Luigel\\Paymongo\\Tests\\PaymentTest::it_can_create_payment":1.098,"Luigel\\Paymongo\\Tests\\PaymentTest::it_cannot_create_payment_when_token_is_used_more_than_once":1.455,"Luigel\\Paymongo\\Tests\\PaymentTest::it_cannot_create_payment_when_token_is_not_valid":1.493,"Luigel\\Paymongo\\Tests\\PaymentTest::it_can_retrieve_a_payment":1.48,"Luigel\\Paymongo\\Tests\\PaymentTest::it_can_not_retrieve_a_payment_with_invalid_id":0.888,"Luigel\\Paymongo\\Tests\\PaymentTest::it_can_get_all_payments":0.965,"Luigel\\Paymongo\\Tests\\PaymongoValidateSignatureTest::it_will_not_allow_invalid_signature":0.007,"Luigel\\Paymongo\\Tests\\PaymongoValidateSignatureTest::it_will_allow_valid_signature":0.007,"Luigel\\Paymongo\\Tests\\SourceTest::it_can_create_a_gcash_source":0.407,"Luigel\\Paymongo\\Tests\\SourceTest::it_can_create_a_grab_pay_source":0.412,"Luigel\\Paymongo\\Tests\\TokenTest::it_can_create_token":0.464,"Luigel\\Paymongo\\Tests\\TokenTest::it_cannot_create_token_with_invalid_data":0.388,"Luigel\\Paymongo\\Tests\\TokenTest::it_can_retrieve_token":0.853,"Luigel\\Paymongo\\Tests\\UnauthorizedTest::it_expects_unauthorized_exception_with_invalid_api_keys":0.39,"Luigel\\Paymongo\\Tests\\WebhookTest::it_can_list_all_webhooks":0.4,"Luigel\\Paymongo\\Tests\\WebhookTest::it_can_retrieve_webhook":0.786,"Luigel\\Paymongo\\Tests\\PaymentIntentTest::it_can_attach_paymaya_payment_method_to_payment_intent":1.322}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -53,7 +53,7 @@ $cancelledPaymentIntent = $paymentIntent->cancel(); | |
Attach the payment intent. | ||
|
||
### Sample | ||
|
||
1. Simple attaching of payment method in payment intent. | ||
```php | ||
use Luigel\Paymongo\Facades\Paymongo; | ||
|
||
|
@@ -62,6 +62,44 @@ $paymentIntent = Paymongo::paymentIntent()->find('pi_hsJNpsRFU1LxgVbxW4YJHRs6'); | |
$successfulPayment = $paymentIntent->attach('pm_wr98R2gwWroVxfkcNVZBuXg2'); | ||
``` | ||
|
||
2. Attaching paymaya payment method in payment intent. | ||
```php | ||
$paymentIntent = Paymongo::paymentIntent() | ||
->create([ | ||
'amount' => 100, | ||
'payment_method_allowed' => [ | ||
'paymaya', 'card' // <--- Make sure to add paymaya here. | ||
], | ||
'payment_method_options' => [ | ||
'card' => [ | ||
'request_three_d_secure' => 'automatic', | ||
], | ||
], | ||
'description' => 'This is a test payment intent', | ||
'statement_descriptor' => 'LUIGEL STORE', | ||
'currency' => 'PHP', | ||
]); | ||
|
||
$paymentMethod = Paymongo::paymentMethod() | ||
->create([ | ||
'type' => 'paymaya', // <--- and payment method type should be paymaya | ||
'billing' => [ | ||
'address' => [ | ||
'line1' => 'Somewhere there', | ||
'city' => 'Cebu City', | ||
'state' => 'Cebu', | ||
'country' => 'PH', | ||
'postal_code' => '6000', | ||
], | ||
'name' => 'Rigel Kent Carbonel', | ||
'email' => '[email protected]', | ||
'phone' => '0935454875545', | ||
], | ||
]); | ||
|
||
$attachedPaymentIntent = $paymentIntent->attach($paymentMethod->id, 'http://example.com/success'); // <--- And the second parameter should be the return_url. | ||
``` | ||
|
||
## Get Payment Intent | ||
|
||
You can retrieve a Payment Intent by providing a payment intent ID. The prefix for the id is `pi_` followed by a unique hash representing the payment. Just pass the payment id to `find($paymentIntentId)` method. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -146,4 +146,48 @@ public function it_can_retrieve_payment_intent() | |
|
||
$this->assertEquals($paymentIntent, $retrievedPaymentIntent); | ||
} | ||
|
||
/** @test */ | ||
public function it_can_attach_paymaya_payment_method_to_payment_intent() | ||
{ | ||
$paymentIntent = Paymongo::paymentIntent() | ||
->create([ | ||
'amount' => 100, | ||
'payment_method_allowed' => [ | ||
'paymaya', 'card', | ||
], | ||
'payment_method_options' => [ | ||
'card' => [ | ||
'request_three_d_secure' => 'automatic', | ||
], | ||
], | ||
'description' => 'This is a test payment intent', | ||
'statement_descriptor' => 'LUIGEL STORE', | ||
'currency' => 'PHP', | ||
]); | ||
|
||
$paymentMethod = Paymongo::paymentMethod() | ||
->create([ | ||
'type' => 'paymaya', | ||
'billing' => [ | ||
'address' => [ | ||
'line1' => 'Somewhere there', | ||
'city' => 'Cebu City', | ||
'state' => 'Cebu', | ||
'country' => 'PH', | ||
'postal_code' => '6000', | ||
], | ||
'name' => 'Rigel Kent Carbonel', | ||
'email' => '[email protected]', | ||
'phone' => '0935454875545', | ||
], | ||
]); | ||
|
||
$attachedPaymentIntent = $paymentIntent->attach($paymentMethod->id, 'http://example.com/success'); | ||
|
||
$this->assertEquals($paymentIntent->id, $attachedPaymentIntent->id); | ||
$this->assertEquals('awaiting_next_action', $attachedPaymentIntent->status); | ||
$this->assertEquals('redirect', $attachedPaymentIntent->next_action['type']); | ||
$this->assertNotNull($attachedPaymentIntent->next_action['redirect']['url']); | ||
} | ||
} |
9937e8a
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs: