paymaya / paymaya-php-sdk Goto Github PK
View Code? Open in Web Editor NEWPHP SDK for PayMaya REST APIs https://developers.paymaya.com/blog/entry/paymaya-api-and-sdk-documentation
License: MIT License
PHP SDK for PayMaya REST APIs https://developers.paymaya.com/blog/entry/paymaya-api-and-sdk-documentation
License: MIT License
------ ----------------------------------------------------------------
Line PayMaya/API/Checkout.php
------ ----------------------------------------------------------------
37 Access to an undefined property PayMaya\API\Checkout::$id.
45 Access to an undefined property PayMaya\API\Checkout::$id.
48 Access to an undefined property PayMaya\API\Checkout::$status.
------ ----------------------------------------------------------------
Discovered by @phpstan
Description of an item was not displayed in checkout page
No package found on Packagist, and there are important meta-information left out.
I get this message when trying to install the SDK via composer. I am using Laravel Framework for this
D:\Files and Projects\Projects\SakuraSmartWeb>composer require "paymaya/paymaya-sdk:*"./composer.json has been updated
Loading composer repositories with package information
Updating dependencies (including require-dev)
Your requirements could not be resolved to an installable set of packages.
Problem 1
- Installation request for psr/log (locked at 1.1.2) -> satisfiable by psr/log[1.1.2].
- paymaya/paymaya-sdk 0.0.2 requires psr/log 1.0.2 -> satisfiable by psr/log[1.0.2].
- paymaya/paymaya-sdk dev-curl-error-patch requires psr/log 1.0.2 -> satisfiable by psr/log[1.0.2].
- paymaya/paymaya-sdk dev-dev-master requires psr/log 1.0.2 -> satisfiable by psr/log[1.0.2].
- paymaya/paymaya-sdk dev-master requires psr/log 1.0.2 -> satisfiable by psr/log[1.0.2].
- Conclusion: don't install psr/log 1.0.2
- paymaya/paymaya-sdk 0.0.1 requires psr/log 1.0.0 -> satisfiable by psr/log[1.0.0].
- paymaya/paymaya-sdk dev-dev requires psr/log 1.0.0 -> satisfiable by psr/log[1.0.0].
- Conclusion: don't install psr/log 1.0.0
- Installation request for paymaya/paymaya-sdk * -> satisfiable by paymaya/paymaya-sdk[0.0.1, 0.0.2, dev-curl-error-patch, dev-dev, dev-dev-master, dev-master].
Installation failed, reverting ./composer.json to its original content.
$successWebhook = new Webhook();
$successWebhook->id = $itemCheckout->id;
$successWebhook->name = Webhook::CHECKOUT_SUCCESS;
$successWebhook->callbackUrl = "http://localhost:8000/paymaya/success";
$successWebhook->register();
i was getting this error, I'm using Symfony Framework 3.3
Undefined index: ID
even though I already set the ID returned by PayMaya Checkout.
Am I missing something?
Here is my code:
`<?php
require __DIR__ . '/vendor/autoload.php';
use PayMaya\PayMayaSDK;
use PayMaya\API\Checkout;
use PayMaya\Model\Checkout\Item;
use PayMaya\Model\Checkout\ItemAmount;
use PayMaya\Model\Checkout\ItemAmountDetails;
use PayMaya\Model\Checkout\Buyer;
use PayMaya\Model\Checkout\Address;
use PayMaya\Model\Checkout\Contact;
class PaymayaClass{
private $publicApiKey;
private $secretApiKey;
private $environment;
function __construct($config){
$this->publicApiKey = $config['publicApiKey'];
$this->secretApiKey = $config['secretApiKey'];
$this->environment = $config['environment'];
}
function checkout($paymentArray){
PayMayaSDK::getInstance()->initCheckout($this->publicApiKey, $this->secretApiKey, $this->environment);
$itemCheckout = new Checkout();
$itemAmountDetails = new ItemAmountDetails();
$itemAmountDetails->shippingFee = $paymentArray['shippingFee'];
$itemAmountDetails->tax = $paymentArray['tax'];
$itemAmountDetails->subtotal = $paymentArray['subTotal'];
$itemAmount = new ItemAmount();
$itemAmount->currency = $paymentArray['currency'];
$itemAmount->value = $paymentArray['totalAmount'];
$itemAmount->details=$itemAmountDetails;
$item = new Item();
$item->name=$paymentArray['itemName'];
$item->code=$paymentArray['itemCode'];
$item->description=$paymentArray['itemDescription'];
$item->quantity=$paymentArray['quantity'];
$item->amount=$itemAmount;
$item->totalAmount = $itemAmount;
$itemCheckout->items = array($item);
$itemCheckout->totalAmount = $itemAmount;
$itemCheckout->requestReferenceNumber='123';
$itemCheckout->redirectUrl = array(
'success'=>'https://demo.hamiliserver.com/APIReceiver/',
'faliure'=>'https://demo.hamiliserver.com/APIReceiver/',
'cancel'=>'https://demo.hamiliserver.com/APIReceiver/'
);
$itemCheckout->execute();
}
}
?>
`
on command 'compose require composer require "paymaya/paymaya-sdk:*"'
cli error appear: ''Conclusion: don't install psr/log 1.0.2"
Note: this is in Laravel 7
@ebcayabyab I see only code for the Checkout API, when is the Purchase API code expected to be done?
I developed a library in Laravel: https://github.com/aceraven777/laravel-paymaya
This library was based on this SDK library.
I have a user here that raised an issue: aceraven777/laravel-paymaya#15
He said that the sandbox credentials are working, but the production credentials don't work, can someone help me investigate this issue?
Good Day Paymaya,
I was testing php sdk in sandbox environment.
I was following your checkout example here:
https://github.com/PayMaya/PayMaya-PHP-SDK/blob/master/sample/Checkout/ItemCheckout.php
When I reach line 45 of your sample code as shown below:
$itemCheckout->retrieve();
I encounter these error:
Undefined index: voidStatus (8)
Undefined index: metadata (8)
The code involved is:
File: lib/PayMaya/API/Checkout.php
Function: retrieve
Upon investigation, the returned json indeed did not have fields voidStatus and metadata.
Below is sample response:
{
"merchant":{
"currency":"PHP",
"name":"Test Merchant for Core 5",
"email":"[email protected]",
"locale":"en",
"homepageUrl":"http://paymaya.com",
"isEmailToMerchantEnabled":true,
"isEmailToBuyerEnabled":true,
"isPaymentFacilitator":false,
"isPageCustomized":true,
"supportedSchemes":[
"Mastercard",
"Visa"
],
"expressCheckout":false,
"canPayPal":false
},
"buyer":{
"firstName":"John",
"middleName":"Michaels",
"lastName":"Doe",
"contact":{
"phone":"+63(2)1234567890",
"email":"[email protected]"
},
"shippingAddress":{
"line1":"9F Robinsons Cybergate 3",
"line2":"Pioneer Street",
"city":"Mandaluyong City",
"state":"Metro Manila",
"zipCode":"12345",
"countryCode":"PH"
},
"billingAddress":{
"line1":"9F Robinsons Cybergate 3",
"line2":"Pioneer Street",
"city":"Mandaluyong City",
"state":"Metro Manila",
"zipCode":"12345",
"countryCode":"PH"
}
},
"items":[
{
"name":"Leather Belt",
"code":"pm_belt",
"description":"Medium-sized belt made from authentic leather",
"quantity":"1",
"amount":{
"value":"69.00",
"details":{
"discount":"0.00",
"serviceCharge":"0.00",
"shippingFee":"14.00",
"tax":"5.00",
"subtotal":"50.00"
}
},
"totalAmount":{
"value":"69.00",
"details":{
"discount":"0.00",
"serviceCharge":"0.00",
"shippingFee":"14.00",
"tax":"5.00",
"subtotal":"50.00"
}
}
}
],
"status":"CREATED",
"id":"ee0e3f70-c200-4812-8c4c-02ababa4fbb3",
"totalAmount":{
"currency":"PHP",
"value":"69.00",
"details":{
"discount":"0.00",
"serviceCharge":"0.00",
"shippingFee":"14.00",
"tax":"5.00",
"subtotal":"50.00"
}
},
"requestReferenceNumber":"123456789",
"transactionReferenceNumber":null,
"receiptNumber":null,
"createdAt":"2017-10-30T13:12:57.612Z",
"updatedAt":"2017-10-30T13:12:57.612Z",
"expiredAt":"2017-10-30T14:12:57.605Z",
"paymentType":"CREDIT_CARD",
"paymentStatus":"PENDING",
"redirectUrl":{
"success":"https://shop.com/success",
"failure":"https://shop.com/failure",
"cancel":"https://shop.com/cancel"
},
"refundedAmount":"0",
"expressCheckout":false,
"canPayPal":false
}
Thank you.
No paymentType in responses. I assumed it's paymentScheme now.
this is the json response I got.
"merchant" => array:14 [▶]
"buyer" => []
"items" => array:1 [▶]
"status" => "CREATED"
"id" => "ca23efd8-9017-4e35-9af1-7d7ab4846c41"
"totalAmount" => array:3 [▶]
"requestReferenceNumber" => "46fe3f6241ee479153965a056a114dd95"
"transactionReferenceNumber" => null
"receiptNumber" => null
"createdAt" => "2017-11-10T08:57:40.624Z"
"updatedAt" => "2017-11-10T08:57:40.624Z"
"expiredAt" => "2017-11-10T09:57:40.622Z"
"paymentScheme" => "CREDIT_CARD"
"paymentStatus" => "PENDING"
"redirectUrl" => array:3 [▶]
"refundedAmount" => "0"
"expressCheckout" => false
"canPayPal" => false
The default cURL options in PayMaya\Core\HTTPConfig
are fixed and are not very flexible. There are installations of PHP 5.6 and above where libcurl
uses NSS instead of OpenSSL as the SSL/TLS provider, which means hard-coding CURLOPT_SSL_CIPHER_LIST
to 'TLSv1'
will be incompatible to these PHP installations, after setting said options through curl_setopt_array()
in PayMaya\Core\HTTPConnection::execute()
, as 'TLSv1'
is only a valid value if OpenSSL is cURL's back-end. (See https://curl.haxx.se/libcurl/c/CURLOPT_SSL_CIPHER_LIST.html)
In addition, it is best to leave CURLOPT_SSLVERSION
alone. See the corresponding entry at https://www.php.net/manual/en/function.curl-setopt.php for a description.
In closing, I highly recommend removing the CURLOPT_SSL_CIPHER_LIST
and CURLOPT_SSLVERSION
options from PayMaya\Core\HTTPConfig
for better compatibility. The API's web server configuration on the other hand will be able to dictate which ciphers to be used on negotiation anyway. See the ssl_protocols
, ssl_ciphers
, and ssl_prefer_server_ciphers
directives for NGINX as examples.
Trying to run your sample code and encountered an error.
<br /> <b>Fatal error</b>: Uncaught Exception: Error API call in /storage/ssd4/275/12315275/public_html/paymaya/vendor/paymaya/paymaya-sdk/lib/PayMaya/Core/HTTPConnection.php:50 Stack trace: #0 /storage/ssd4/275/12315275/public_html/paymaya/vendor/paymaya/paymaya-sdk/lib/PayMaya/Core/CheckoutAPIManager.php(57): PayMaya\Core\HTTPConnection->execute('{"url":null,"bu...') #1 /storage/ssd4/275/12315275/public_html/paymaya/vendor/paymaya/paymaya-sdk/lib/PayMaya/API/Checkout.php(34): PayMaya\Core\CheckoutAPIManager->initiateCheckout(Array) #2 /storage/ssd4/275/12315275/public_html/paymaya/vendor/paymaya/paymaya-sdk/sample/Checkout/ItemCheckout.php(44): PayMaya\API\Checkout->execute() #3 {main} thrown in <b>/storage/ssd4/275/12315275/public_html/paymaya/vendor/paymaya/paymaya-sdk/lib/PayMaya/Core/HTTPConnection.php</b> on line <b>50</b><br />
When I try to do a checkout, its returning:
array:2 [▼
"code" => "PY0001"
"message" => "A problem is encountered. Please contact your system administrator."
]
It was working last time. I tried all of the API keys here: https://developers.paymaya.com/blog/entry/checkout-api-test-credit-card-account-numbers
But none of them works.
I tried all the keys in https://developers.paymaya.com/blog/entry/checkout-api-test-credit-card-account-numbers but they all returns key is expired
Good Day,
Is your sample code or syntax for PayMaya PHP still working? because it seems outdated when I look at the syntax in your guide isn't?, because I'm looking for a code for how to write a Request to make a payment in PHP, this documentation("https://s3-us-west-2.amazonaws.com/developers.paymaya.com.pg/pay-by-paymaya/index.html#scan-dynamic-qr-payment-create-payment-post") just shows the header and the body of the Request but don't have a guide how to create a Request in PHP, could you help me where can I find a complete guide how to create a Request for create payment in PHP?
Hi. I'd like to know when will this be ready for production use?
Thanks. Any response is much appreciated.
Also, I suggest you use SemVer (as composer recommends) for your release version pattern.
I have followed the example given, when I try to retrieve checkout method it gives me an error of Undefined index: paymentType. what would I do?
Request:
It would be nice you can adjust psr/log dependency to support version > 1.0,
at least to update composer.json to require ~1.0.
I encountered this dependency version conflict on laravel5.4 as all module requires ~1.0. (1.0.2 specifically) and the sdk is trying to install 1.0.0 version.
Problem 1
- Can only install one of: psr/log[1.0.0, 1.0.2]. <-- trying to install two version
- Can only install one of: psr/log[1.0.2, 1.0.0].
- Can only install one of: psr/log[1.0.0, 1.0.2].
- paymaya/paymaya-sdk 0.0.1 requires psr/log 1.0.0 -> satisfiable by psr/log[1.0.0].
- Installation request for paymaya/paymaya-sdk * -> satisfiable by paymaya/paymaya-sdk[0.0.1].
- Installation request for psr/log (locked at 1.0.2, required as ^1.0) -> satisfiable by psr/log[1.0.2].
It would be better to have inline doc blocks for API documentation. I'll contribute along the way once I figure out how to use the SDK. Very promising.
I'm using PayMaya checkout: https://hackmd.io/@paymaya-pg/Checkout
How do I add "Pay with PayMaya" to accept wallet payment?
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.