luigel / laravel-paymongo Goto Github PK
View Code? Open in Web Editor NEWA laravel wrapper for Paymongo API
Home Page: https://paymongo.rigelkentcarbonel.com
License: MIT License
A laravel wrapper for Paymongo API
Home Page: https://paymongo.rigelkentcarbonel.com
License: MIT License
PHP version:
PHP 7.3.8 (cli) (built: Aug 11 2019 20:50:16) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.3.8, Copyright (c) 1998-2018 Zend Technologies
with Zend OPcache v7.3.8, Copyright (c) 1999-2018, by Zend Technologies
with Xdebug v2.7.2, Copyright (c) 2002-2019, by Derick Rethans
Laravel version:
Laravel Framework 7.28.3
Package version:
luigel/laravel-paymongo : ^1.3.1
Paymongo only accepts integer in the argument amount,
looking at the package, we have a method there convertPayloadAmountsToInteger($payload)
that converts the passed amount from app to package class.
In the app we are developing, our products price are in hundredth decimal (P 112.529)
Passing this in Paymongo::paymentIntent->create([]), returns a paymongo exception
"amount should be an integer"
1. Please create a file tests/AmounToIntegerTest.php
2. Copy this code into tests/AmounToIntegerTest.php
<?php
namespace Luigel\Paymongo\Tests;
use Luigel\Paymongo\Models\BaseModel;
use Luigel\Paymongo\Traits\Request;
class AmounToIntegerTest extends BaseTestCase
{
use Request;
/** @test */
public function it_can_convert_without_decimal()
{
$payload = [
'amount' => 147
];
$convertedPayload = $this->convertPayloadAmountsToInteger($payload);
$this->assertIsInt($convertedPayload['amount']);
$this->assertIsNotFloat($convertedPayload['amount']);
}
/** @test */
public function it_can_convert_with_in_tenth_decimal()
{
$payload = [
'amount' => 147.95
];
$convertedPayload = $this->convertPayloadAmountsToInteger($payload);
$this->assertIsInt($convertedPayload['amount']);
$this->assertIsNotFloat($convertedPayload['amount']);
}
/** @test */
public function it_can_convert_with_in_hundredth_decimal()
{
$payload = [
'amount' => 254.950
];
$convertedPayload = $this->convertPayloadAmountsToInteger($payload);
$this->assertIsInt($convertedPayload['amount']);
$this->assertIsNotFloat($convertedPayload['amount']);
}
}
3. composer test
There were 2 failures:
1) Luigel\Paymongo\Tests\AmounToIntegerTest::it_can_convert_with_in_tenth_decimal
Failed asserting that 14794.999999999998 is of type "int".
/Users/macbook/Documents/Docker/nutriasia/laravel-paymongo/tests/AmounToIntegerTest.php:34
2) Luigel\Paymongo\Tests\AmounToIntegerTest::it_can_convert_with_in_hundredth_decimal
Failed asserting that 25495.0 is of type "int".
/Users/macbook/Documents/Docker/nutriasia/laravel-paymongo/tests/AmounToIntegerTest.php:47
FAILURES!
Tests: 3, Assertions: 4, Failures: 2.
Expected behavior:
Assuming we have
147.95
should return 14795
254.950
should return 25495
Actual behavior:
Assuming we have
147
convertPayloadAmountsToInteger() will return it as 14700
this is integer (correct)
147.95
convertPayloadAmountsToInteger() will return it as 14794.999999999998
this is not an integer (error)
254.950
convertPayloadAmountsToInteger() will return it as 25495.0
this is not an integer (error)
none
I used the code below to test the payment intent but it returns null when I used dd($paymentIntent);
PaymentMethod is working but the paymentintent create method is not working on my end.
$paymentIntent = Paymongo::paymentIntent()->create([
'amount' => 10000,
'payment_method_allowed' => [
'card'
],
'payment_method_options' => [
'card' => [
'request_three_d_secure' => 'automatic'
]
],
'description' => 'This is a test payment intent',
'statement_descriptor' => 'LUIGEL STORE',
'currency' => "PHP"
]);
dd($paymentIntent);
Note:
Expected behavior:
Actual behavior:
Any additional information, configuration or data that might be necessary to reproduce the issue.
Note that I am receiving the json payload from paymongo with no error.
However when I am trying to use middlewares for my webhooks specifically for payment.paid
and payment.failed
events, I am still receiving the json payload but then after that there's an error in the logs. So I am not sure if it is validating the signature properly.
Expected behavior:
Receving the json payload from paymongo with no error.
Actual behavior:
Receiving an error message in the logs:
Luigel\Paymongo\Middlewares\PaymongoValidateSignature::handle(): Return value must be of type ?Illuminate\Http\Response, Illuminate\Http\JsonResponse returned {"exception":"[object] (TypeError(code: 0): Luigel\\Paymongo\\Middlewares\\PaymongoValidateSignature::handle(): Return value must be of type ?Illuminate\\Http\\Response, Illuminate\\Http\\JsonResponse returned at /home/vagrant/code/web/others/laravel/booking-laravel-filament/vendor/luigel/laravel-paymongo/src/Middlewares/PaymongoValidateSignature.php:27)
How to mock this function?
Paymongo::source()->create([
'type' => 'gcash',
'amount' => 100,
'currency' => 'PHP',
'redirect' => [
'success' => 'http://localhost/success',
'failed' => 'http://localhost/failed'
]
])
in my test file
Paymongo::shouldReceive('source')
->shouldReceive('create')
->andReturn(json_decode('
{
"data": {
"id": "gg",
"type": "source",
"attributes": {
"amount": 10000,
"billing": null,
"currency": "PHP",
"description": null,
"livemode": false,
"redirect": {
"checkout_url": "https://test-sources.paymongo.com/sources?id=gg",
"failed": "http://localhost/failed",
"success": "http://localhost/success"
},
"statement_descriptor": null,
"status": "pending",
"type": "gcash",
"created_at": 1648140991,
"updated_at": 1648140991
}
}
}',true));
but i got this error Call to a member function create() on null
I want to customize the error callback attribute or message.
Any additional information, configuration or data that might be needed to understand the proposal.
Do I need to create a webhook or i can just directly use this?
$gcashSource = Paymongo::source()->create([
'type' => 'gcash',
'amount' => 100.00,
'currency' => 'PHP',
'redirect' => [
'success' => 'http://localhost:8000/success',
'failed' => 'http://localhost:8000/failed'
]
]);
actually i didn't understand when to use webhook
Add support for refunding transactions
https://developers.paymongo.com/docs/refunding-transactions
Please add documentation on the amount value conversion used by the package.
The function convertPayloadAmountsToInteger
conflicts a little bit with PayMongo's documentation.
PayMongo's documentation says that the amount value should be an integer.
However, this package's code does the conversion to integer automatically.
Here are my suggestions for this issue. Kindly check which works best
config/paymongo.php
so that devs can decide to use the package's own conversion or not.'amount' => 100.50',
in the example code in the documentation (reference: https://paymongo.rigelkentcarbonel.com/payment-intents#sample-2). However, I think the package might still conflict with other PHP packages like moneyphp/money (which I'm currently using)Thank you!
After creating a source and receiving a webhook data I'm using Paymongo::payment() to create a payment for the source.chargeable.
I get this error "Call to undefined method Luigel\Paymongo\Paymongo::payment()". But the method exists.
Request for new feature Checkout API
Expected behavior:
Actual behavior:
Any additional information, configuration or data that might be necessary to reproduce the issue.
Expected behavior:
Actual behavior:
Any additional information, configuration or data that might be necessary to reproduce the issue.
Server error:
POST https://api.paymongo.com/v1/sources/` resulted in a 500 Internal Server Error
response: {"errors":[{"detail":"Something went wrong on our end. We have been notified and will be investigating. Trust us, these (truncated...)`
Hi, your library is great, but I'm facing an issue when using grab_pay and gcash as payment. This occur after a success request then redirect to their checkout_url, I tried to follow their documentation just to check if it's working well in their end, but it also giving the same error response. I know this is not your bug, I'm just letting you know lol
https://developers.paymongo.com/reference/links-resource
PRs are welcome. ๐
Hello dev team
Paymaya is supported?
Requesting Paymaya API Integration to be added to this package https://developers.paymongo.com/docs/accepting-paymaya-payments
Is this gcash supported? because many are gcash user here in philippines
$validator = Validator::make(
$data,
$rules, <--- remove comma here
);
Expected behavior:
Actual behavior:
Any additional information, configuration or data that might be necessary to reproduce the issue.
Cancelling a Payment Intent throws an error exception of BadRequestException
:
"message": "Payment intent with id pi_BRbuVgVdZpGar5EjzSSf1ce7 has succeeded.",
"exception": "Luigel\\Paymongo\\Exceptions\\BadRequestException",
"file": "/var/www/sample/vendor/luigel/laravel-paymongo/src/Traits/Request.php",
"line": 220,
"trace": [
{
"file": "/var/www/sample/vendor/luigel/laravel-paymongo/src/Traits/Request.php",
"line": 171,
"function": "request",
"class": "Luigel\\Paymongo\\Paymongo",
"type": "->"
},
{
"file": "/var/www/sample/vendor/luigel/laravel-paymongo/src/Models/PaymentIntent.php",
"line": 148,
"function": "cancel",
"class": "Luigel\\Paymongo\\Paymongo",
"type": "->"
}
Expected behavior:
Payment Intent should be cancelled successfully.
Actual behavior:
Produces a BadRequestException
error.
Checking on PayMongo's API documentation, I don't see a way of cancelling Payment Intents. Maybe it was removed? I could only see creating, fetching, and attaching it to a Payment Method.
Also trying to access the endpoint URL gives 404/blank page:
https://api.paymongo.com/v1/payment_intents/pi_BRbuVgVdZpGar5EjzSSf1ce7/cancel
The cancel endpoint for Payment Intents might have been removed.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.