omise / omise-php Goto Github PK
View Code? Open in Web Editor NEWOmise PHP library
Home Page: https://docs.opn.ooo
License: MIT License
Omise PHP library
Home Page: https://docs.opn.ooo
License: MIT License
Hi I just get started and follow this guide
https://www.omise.co/omise-js-api
and somehow got error at
$charge = OmiseCharge::create(array(
'amount' => 10025,
'currency' => 'thb',
'card' => $_POST["omiseToken"]
));
and I some how fix it with manual curl like
<?php
// create curl resource
$ch = curl_init();
// set url
curl_setopt($ch, CURLOPT_URL, "https://api.omise.co/charges" );
curl_setopt($ch, CURLOPT_POST, 1 );
curl_setopt($ch, CURLOPT_USERPWD, "{{$PRIVATE_KEY}}:");//-u
$postdata = array(
'description' => 'Test curl',
'amount' => "570000",
'currency' => 'thb',
'return_uri' => "{{$REDIRECT_URL}}",
'card' => $_POST['omiseToken']
)
;
curl_setopt($ch, CURLOPT_POSTFIELDS, $postdata);
//return the transfer as a string
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
// $output contains the output string
$output = curl_exec($ch);
// close curl resource to free up system resources
curl_close($ch);
$result = json_decode($output);
if($result->status == "successful"){
$newURL = "{{$REDIRECT_URL}}";
header('Location: '.$newURL);
}
else
print_r($result);
?>
Code like this:
$omise_id = 'cust_test_111';
$omise_public = 'pkey_test_111';
$omise_secret = 'skey_test_111';
$card_id = 'card_test_111';
$customer = OmiseCustomer::retrieve($omise_id, $omise_public, $omise_secret);
$card = $customer->cards()->retrieve($card_id);
$customer->cards()
will return new OmiseCardList, and set $publickey & $secretkey to it.
however, it didn't call self::getInstance to set $instances array with keys, when $customer->cards()->retrieve
(OmiseCardList@retrieve) , here call self::getResourceKey()
, will receive empty or ENV key, not code var key.
Please make sure if this is a bug or a problem with my code.
omise-php 2.17.0
php 8.2
I do not see any design document yet, so I propose a new one here:
If Omise is going to create a new 3-0-0 release, if backward compatibility is not an issue, I would like to propose 2 new designs:
static
as usual, but add service locator pattern for testability. Bonus: this can be partially implemented on 2.x.use \Http\Client\HttpClient;
use \Omise\Credential\CredentialProvider;
use \Omise\Credential\EnvarCredentialProvider;
use \Omise\OmiseClient;
use \Omise\TestSupport\FixtureHttpClient;
use \Omise\ServiceLocator;
class ChargeTest
{
public function setUp()
{
$locator = ServiceLocator::getInstance();
$locator->restoreDefault();
}
public function testListCharges()
{
$locator = ServiceLocator::getInstance();
$locator->register(HttpClient::class, function () {
return new FixtureHttpClient(__DIR__.'/../fixtures/'));
});
$locator->register(
CredentialProvider::class,
function () {
return new EnvarCredentialProvider('OMISE_PUBLIC_KEY', 'OMISE_SECRET_KEY');
}
);
$charge_list = OmiseClient::listCharges();
$this->assertInstanceOf('\Omise\Resorce\List', $charge_list);
foreach ($charge_list->data() as $charge) {
$this->assertInstanceOf('\Omise\Resource\Charge', $charge);
}
// backward compatibility is still partially supported
$charge_list = OmiseCharge::retrieve();
$this->assertInstanceOf('\Omise\Resorce\List', $charge_list);
foreach ($charge_list->data() as $charge) {
$this->assertInstanceOf('\Omise\Resource\Charge', $charge);
}
}
}
The idea:
static
, for ease of use.define
constants, for testability. (One may use class constant, if it's really a constant.)FixtureHttpClient implements \Http\Client\HttpClient
is a way to handle fixture testing, it decouples fixture management from core code that usually resides in OmiseApiResource
.EnvarCredentialProvider implements \Omise\Credential\CredentialProvider
is an example of various ways to configure pkey/skey
secret, one may use static coded, Hashicorp's Vault, or even AWS's Parameter Store, Azure's KeyVault, this one reads from environment variable which works well on dev box.OmiseClient
is a facade to all Omise APIs and libraries.Edit
static
still have the same problem testing plugins that user wants to mock OmiseClient
to test their plugin only.static
methods, no service locator, all hard wired.use \Omise\Credential\EnvarCredentialProvider;
use \Omise\OmiseClient;
use \Omise\TestSupport\FixtureHttpClient;
class ChargeTest
{
public function testListCharges()
{
$http_client = new FixtureHttpClient(__DIR__.'/../fixtures/');
$credential_provider = new EnvarCredentialProvider('OMISE_PUBLIC_KEY', 'OMISE_SECRET_KEY');
$omise_client = new OmiseClient($credential_provider, $http_client);
$charge_list = $omise_client->listCharges();
$this->assertInstanceOf('\Omise\Resorce\List', $charge_list);
foreach ($charge_list->data() as $charge) {
$this->assertInstanceOf('\Omise\Resource\Charge', $charge);
}
}
}
The idea:
static
methods, for testability.define
constants, for testability. (One may use class constant, if it's really a constant.)FixtureHttpClient implements \Http\Client\HttpClient
is a way to handle fixture testing, it decouples fixture management from core code that usually resides in OmiseApiResource
.EnvarCredentialProvider implements \Omise\Credential\CredentialProvider
is an example of various ways to configure pkey/skey
secret, one may use static coded, Hashicorp's Vault, or even AWS's Parameter Store, Azure's KeyVault, this one reads from environment variable which works well on dev box.OmiseClient
is a facade to all Omise APIs and libraries.One unanswered question: $charge['captured']
versus $charge->captured()
, does dynamic array access still make sense?
Implement extension for Omnipay
Omnipay is a collection of packages which all depend on the omnipay/common package to provide a consistent interface. There are no dependencies on official payment gateway PHP packages - we prefer to work with the HTTP API directly. Under the hood, we use the popular and powerful PHP-HTTP library to make HTTP requests. A Guzzle adapter is required by default, when using league/omnipay.
New gateways can be created by cloning the layout of an existing package. When choosing a name for your package, please donβt use the omnipay vendor prefix, as this implies that it is officially supported. You should use your own username as the vendor prefix, and prepend omnipay- to the package name to make it clear that your package works with Omnipay. For example, if your GitHub username was santa, and you were implementing the giftpay payment library, a good name for your composer package would be santa/omnipay-giftpay.
Any purpose about why the library is not using namespace?
Static call like the following warn over strict error. And deprecation error from php 5.6.
$resource = $clazz::getInstance($clazz, $publickey, $secretkey);
Tried to install omise for php
Command on PowerShell
composer install
Errors log:
Loading composer repositories with package information
Updating dependencies (including require-dev)
- Installing omise/omise-php (dev-master c7a49d4)
Downloading: 100%
Failed to download omise/omise-php from dist: There was an error extracting the ZIP file, it is either corrupted or using an invalid format.
Now trying to download from source
- Installing omise/omise-php (dev-master c7a49d4)
Cloning c7a49d442a7bbf20b280bd85e9dc1ba17ddc54c4 from cache
c7a49d442a7bbf20b280bd85e9dc1ba17ddc54c4 is gone (history was rewritten?)
[RuntimeException]
Failed to execute git checkout "c7a49d442a7bbf20b280bd85e9dc1ba17ddc54c4" -- && git reset --hard "c7a49d442a7bbf20b280bd85e9dc1ba17ddc54c4" --
Note: checking out 'c7a49d442a7bbf20b280bd85e9dc1ba17ddc54c4'.
You are in 'detached HEAD' state. You can look around, make experimental
changes and commit them, and you can discard any commits you make in this
state without impacting any branches by performing another checkout.
If you want to create a new branch to retain commits you create, you may
do so (now or later) by using -b with the checkout command again. Example:
git checkout -b <new-branch-name>
HEAD is now at c7a49d4... Merge pull request #37 from omise/code-revise
error: unable to create file tests/fixtures/api.omise.co/customers/cust_test_5234fzk37pi2mz0cen3/cards/?limit=1-get.json: Invalid argument
fatal: Could not reset index file to revision 'c7a49d442a7bbf20b280bd85e9dc1ba17ddc54c4'.
composer.json
...
"require" : {
"omise/omise-php": "dev-master",
},
...
How could I fix it , how to prevent this in the future ?
There is a public offsetGet()
method, but it returns only a particular element of the _values
array, and there is no way to get the _values
array at the whole.
https://github.com/omise/omise-php/blob/v2.6.0/lib/omise/res/obj/OmiseObject.php#L5-L6
Error occurs when customer clicks on Checkout cart after adding product to cart.
Magento 2.3.4
Omise 2.16.0
1 exception(s):
Exception #0 (Exception): Warning: array_map(): Argument #2 should be an array in /var/www/html/vendor/omise/omise-php/lib/omise/OmiseCapabilities.php on line 79
Exception #0 (Exception): Warning: array_map(): Argument #2 should be an array in /var/www/html/vendor/omise/omise-php/lib/omise/OmiseCapabilities.php on line 79
<pre>#1 array_map(&Closure#00000000453b45170000000012202126#, NULL) called at [vendor/omise/omise-php/lib/omise/OmiseCapabilities.php:79]
#2 OmiseCapabilities->getBackends(&Closure#00000000453b451f0000000012202126#) called at [vendor/omise/omise-magento/Model/Api/Capabilities.php:29]
#3 Omise\Payment\Model\Api\Capabilities->getInstallmentBackends() called at [vendor/omise/omise-magento/Model/Capabilities.php:36]
#4 Omise\Payment\Model\Capabilities->retrieveInstallmentBackends() called at [vendor/omise/omise-magento/Model/Ui/CapabilitiesConfigProvider.php:40]
#5 Omise\Payment\Model\Ui\CapabilitiesConfigProvider->getConfig() called at [vendor/magento/module-checkout/Model/CompositeConfigProvider.php:39]
#6 Magento\Checkout\Model\CompositeConfigProvider->getConfig() called at [vendor/magento/module-checkout/Block/Cart/Shipping.php:65]
#7 Magento\Checkout\Block\Cart\Shipping->getCheckoutConfig() called at [vendor/magento/module-checkout/Block/Cart/Shipping.php:99]
#8 Magento\Checkout\Block\Cart\Shipping->getSerializedCheckoutConfig() called at [vendor/magento/module-checkout/view/frontend/templates/cart/shipping.phtml:37]
#9 include('/var/www/html/ve...') called at [vendor/magento/framework/View/TemplateEngine/Php.php:59]
#10 Magento\Framework\View\TemplateEngine\Php->render(&Magento\Checkout\Block\Cart\Shipping#00000000453b5d550000000012202126#, '/var/www/html/ve...', array()) called at [vendor/magento/framework/View/Element/Template.php:271]
#11 Magento\Framework\View\Element\Template->fetchView('/var/www/html/ve...') called at [vendor/magento/framework/View/Element/Template.php:301]
#12 Magento\Framework\View\Element\Template->_toHtml() called at [vendor/magento/framework/View/Element/AbstractBlock.php:1099]
#13 Magento\Framework\View\Element\AbstractBlock->Magento\Framework\View\Element\{closure}() called at [vendor/magento/framework/View/Element/AbstractBlock.php:1103]
#14 Magento\Framework\View\Element\AbstractBlock->_loadCache() called at [vendor/magento/framework/View/Element/AbstractBlock.php:673]
#15 Magento\Framework\View\Element\AbstractBlock->toHtml() called at [vendor/magento/framework/View/Layout.php:564]
#16 Magento\Framework\View\Layout->_renderBlock('checkout.cart.sh...') called at [vendor/magento/framework/View/Layout.php:540]
#17 Magento\Framework\View\Layout->renderNonCachedElement('checkout.cart.sh...') called at [generated/code/Magento/Framework/View/Layout/Interceptor.php:206]
#18 Magento\Framework\View\Layout\Interceptor->renderNonCachedElement('checkout.cart.sh...') called at [vendor/magento/framework/View/Layout.php:495]
#19 Magento\Framework\View\Layout->renderElement('checkout.cart.sh...', false) called at [generated/code/Magento/Framework/View/Layout/Interceptor.php:193]
#20 Magento\Framework\View\Layout\Interceptor->renderElement('checkout.cart.sh...', false) called at [vendor/magento/framework/View/Layout.php:592]
#21 Magento\Framework\View\Layout->_renderContainer('cart.summary', false) called at [vendor/magento/framework/View/Layout.php:542]
#22 Magento\Framework\View\Layout->renderNonCachedElement('cart.summary') called at [generated/code/Magento/Framework/View/Layout/Interceptor.php:206]
#23 Magento\Framework\View\Layout\Interceptor->renderNonCachedElement('cart.summary') called at [vendor/magento/framework/View/Layout.php:495]
#24 Magento\Framework\View\Layout->renderElement('cart.summary', false) called at [generated/code/Magento/Framework/View/Layout/Interceptor.php:193]
#25 Magento\Framework\View\Layout\Interceptor->renderElement('cart.summary', false) called at [vendor/magento/framework/View/Layout.php:592]
#26 Magento\Framework\View\Layout->_renderContainer('checkout.cart.co...', false) called at [vendor/magento/framework/View/Layout.php:542]
#27 Magento\Framework\View\Layout->renderNonCachedElement('checkout.cart.co...') called at [generated/code/Magento/Framework/View/Layout/Interceptor.php:206]
#28 Magento\Framework\View\Layout\Interceptor->renderNonCachedElement('checkout.cart.co...') called at [vendor/magento/framework/View/Layout.php:495]
#29 Magento\Framework\View\Layout->renderElement('checkout.cart.co...', false) called at [generated/code/Magento/Framework/View/Layout/Interceptor.php:193]
#30 Magento\Framework\View\Layout\Interceptor->renderElement('checkout.cart.co...', false) called at [vendor/magento/framework/View/Layout.php:592]
#31 Magento\Framework\View\Layout->_renderContainer('checkout.cart.it...', false) called at [vendor/magento/framework/View/Layout.php:542]
#32 Magento\Framework\View\Layout->renderNonCachedElement('checkout.cart.it...') called at [generated/code/Magento/Framework/View/Layout/Interceptor.php:206]
#33 Magento\Framework\View\Layout\Interceptor->renderNonCachedElement('checkout.cart.it...') called at [vendor/magento/framework/View/Layout.php:495]
#34 Magento\Framework\View\Layout->renderElement('checkout.cart.it...', true) called at [generated/code/Magento/Framework/View/Layout/Interceptor.php:193]
#35 Magento\Framework\View\Layout\Interceptor->renderElement('checkout.cart.it...', true) called at [vendor/magento/framework/View/Element/AbstractBlock.php:520]
#36 Magento\Framework\View\Element\AbstractBlock->getChildHtml('with-items') called at [vendor/magento/module-checkout/view/frontend/templates/cart.phtml:16]
#37 include('/var/www/html/ve...') called at [vendor/magento/framework/View/TemplateEngine/Php.php:59]
#38 Magento\Framework\View\TemplateEngine\Php->render(&Magento\Checkout\Block\Cart#00000000453b64710000000012202126#, '/var/www/html/ve...', array()) called at [vendor/magento/framework/View/Element/Template.php:271]
#39 Magento\Framework\View\Element\Template->fetchView('/var/www/html/ve...') called at [vendor/magento/framework/View/Element/Template.php:301]
#40 Magento\Framework\View\Element\Template->_toHtml() called at [vendor/magento/framework/View/Element/AbstractBlock.php:1099]
#41 Magento\Framework\View\Element\AbstractBlock->Magento\Framework\View\Element\{closure}() called at [vendor/magento/framework/View/Element/AbstractBlock.php:1103]
#42 Magento\Framework\View\Element\AbstractBlock->_loadCache() called at [vendor/magento/framework/View/Element/AbstractBlock.php:673]
#43 Magento\Framework\View\Element\AbstractBlock->toHtml() called at [vendor/magento/framework/View/Layout.php:564]
#44 Magento\Framework\View\Layout->_renderBlock('checkout.cart') called at [vendor/magento/framework/View/Layout.php:540]
#45 Magento\Framework\View\Layout->renderNonCachedElement('checkout.cart') called at [generated/code/Magento/Framework/View/Layout/Interceptor.php:206]
#46 Magento\Framework\View\Layout\Interceptor->renderNonCachedElement('checkout.cart') called at [vendor/magento/framework/View/Layout.php:495]
#47 Magento\Framework\View\Layout->renderElement('checkout.cart', false) called at [generated/code/Magento/Framework/View/Layout/Interceptor.php:193]
#48 Magento\Framework\View\Layout\Interceptor->renderElement('checkout.cart', false) called at [vendor/magento/framework/View/Layout.php:592]
#49 Magento\Framework\View\Layout->_renderContainer('content', false) called at [vendor/magento/framework/View/Layout.php:542]
#50 Magento\Framework\View\Layout->renderNonCachedElement('content') called at [generated/code/Magento/Framework/View/Layout/Interceptor.php:206]
#51 Magento\Framework\View\Layout\Interceptor->renderNonCachedElement('content') called at [vendor/magento/framework/View/Layout.php:495]
#52 Magento\Framework\View\Layout->renderElement('content', false) called at [generated/code/Magento/Framework/View/Layout/Interceptor.php:193]
#53 Magento\Framework\View\Layout\Interceptor->renderElement('content', false) called at [vendor/magento/framework/View/Layout.php:592]
#54 Magento\Framework\View\Layout->_renderContainer('main', false) called at [vendor/magento/framework/View/Layout.php:542]
#55 Magento\Framework\View\Layout->renderNonCachedElement('main') called at [generated/code/Magento/Framework/View/Layout/Interceptor.php:206]
#56 Magento\Framework\View\Layout\Interceptor->renderNonCachedElement('main') called at [vendor/magento/framework/View/Layout.php:495]
#57 Magento\Framework\View\Layout->renderElement('main', false) called at [generated/code/Magento/Framework/View/Layout/Interceptor.php:193]
#58 Magento\Framework\View\Layout\Interceptor->renderElement('main', false) called at [vendor/magento/framework/View/Layout.php:592]
#59 Magento\Framework\View\Layout->_renderContainer('columns', false) called at [vendor/magento/framework/View/Layout.php:542]
#60 Magento\Framework\View\Layout->renderNonCachedElement('columns') called at [generated/code/Magento/Framework/View/Layout/Interceptor.php:206]
#61 Magento\Framework\View\Layout\Interceptor->renderNonCachedElement('columns') called at [vendor/magento/framework/View/Layout.php:495]
#62 Magento\Framework\View\Layout->renderElement('columns', false) called at [generated/code/Magento/Framework/View/Layout/Interceptor.php:193]
#63 Magento\Framework\View\Layout\Interceptor->renderElement('columns', false) called at [vendor/magento/framework/View/Layout.php:592]
#64 Magento\Framework\View\Layout->_renderContainer('main.content', false) called at [vendor/magento/framework/View/Layout.php:542]
#65 Magento\Framework\View\Layout->renderNonCachedElement('main.content') called at [generated/code/Magento/Framework/View/Layout/Interceptor.php:206]
#66 Magento\Framework\View\Layout\Interceptor->renderNonCachedElement('main.content') called at [vendor/magento/framework/View/Layout.php:495]
#67 Magento\Framework\View\Layout->renderElement('main.content', false) called at [generated/code/Magento/Framework/View/Layout/Interceptor.php:193]
#68 Magento\Framework\View\Layout\Interceptor->renderElement('main.content', false) called at [vendor/magento/framework/View/Layout.php:592]
#69 Magento\Framework\View\Layout->_renderContainer('page.wrapper', false) called at [vendor/magento/framework/View/Layout.php:542]
#70 Magento\Framework\View\Layout->renderNonCachedElement('page.wrapper') called at [generated/code/Magento/Framework/View/Layout/Interceptor.php:206]
#71 Magento\Framework\View\Layout\Interceptor->renderNonCachedElement('page.wrapper') called at [vendor/magento/framework/View/Layout.php:495]
#72 Magento\Framework\View\Layout->renderElement('page.wrapper', false) called at [generated/code/Magento/Framework/View/Layout/Interceptor.php:193]
#73 Magento\Framework\View\Layout\Interceptor->renderElement('page.wrapper', false) called at [vendor/magento/framework/View/Layout.php:592]
#74 Magento\Framework\View\Layout->_renderContainer('root', false) called at [vendor/magento/framework/View/Layout.php:542]
#75 Magento\Framework\View\Layout->renderNonCachedElement('root') called at [generated/code/Magento/Framework/View/Layout/Interceptor.php:206]
#76 Magento\Framework\View\Layout\Interceptor->renderNonCachedElement('root') called at [vendor/magento/framework/View/Layout.php:495]
#77 Magento\Framework\View\Layout->renderElement('root', true) called at [generated/code/Magento/Framework/View/Layout/Interceptor.php:193]
#78 Magento\Framework\View\Layout\Interceptor->renderElement('root') called at [vendor/magento/framework/View/Layout.php:961]
#79 Magento\Framework\View\Layout->getOutput() called at [vendor/magento/framework/Interception/Interceptor.php:58]
#80 Magento\Framework\View\Layout\Interceptor->___callParent('getOutput', array()) called at [vendor/magento/framework/Interception/Interceptor.php:138]
#81 Magento\Framework\View\Layout\Interceptor->Magento\Framework\Interception\{closure}() called at [vendor/magento/framework/Interception/Interceptor.php:153]
#82 Magento\Framework\View\Layout\Interceptor->___callPlugins('getOutput', array(), array(array('layout-model-cac...'))) called at [generated/code/Magento/Framework/View/Layout/Interceptor.php:494]
#83 Magento\Framework\View\Layout\Interceptor->getOutput() called at [vendor/magento/framework/View/Result/Page.php:258]
#84 Magento\Framework\View\Result\Page->render(&Magento\Framework\App\Response\Http\Interceptor#00000000453b6ea30000000012202126#) called at [vendor/magento/framework/View/Result/Layout.php:171]
#85 Magento\Framework\View\Result\Layout->renderResult(&Magento\Framework\App\Response\Http\Interceptor#00000000453b6ea30000000012202126#) called at [vendor/magento/framework/Interception/Interceptor.php:58]
#86 Magento\Framework\View\Result\Page\Interceptor->___callParent('renderResult', array(&Magento\Framework\App\Response\Http\Interceptor#00000000453b6ea30000000012202126#)) called at [vendor/magento/framework/Interception/Interceptor.php:138]
#87 Magento\Framework\View\Result\Page\Interceptor->Magento\Framework\Interception\{closure}(&Magento\Framework\App\Response\Http\Interceptor#00000000453b6ea30000000012202126#) called at [vendor/magento/framework/Interception/Interceptor.php:153]
#88 Magento\Framework\View\Result\Page\Interceptor->___callPlugins('renderResult', array(&Magento\Framework\App\Response\Http\Interceptor#00000000453b6ea30000000012202126#), array(array('result-messages', 'result-builtin-c...', 'result-varnish-c...'), array('updateBodyClass'))) called at [generated/code/Magento/Framework/View/Result/Page/Interceptor.php:39]
#89 Magento\Framework\View\Result\Page\Interceptor->renderResult(&Magento\Framework\App\Response\Http\Interceptor#00000000453b6ea30000000012202126#) called at [vendor/magento/framework/App/Http.php:120]
#90 Magento\Framework\App\Http->launch() called at [vendor/magento/framework/App/Bootstrap.php:261]
#91 Magento\Framework\App\Bootstrap->run(&Magento\Framework\App\Http\Interceptor#00000000453b6ea10000000012202126#) called at [index.php:39]
</pre>
Let user pass a different set of keys in any method that ends up doing a call to the API.
I'm trying to receive a webhook once a user has completed a payment using 3D secure but for some reason Omise isn't picking it up as event or isn't sending out the webhook request. Not sure if it's a problem with my configuration or Omise itself?
$charge = OmiseCharge::create([
'amount' => $package->price(),
'currency' => 'usd',
'capture' => false,
'customer' => $user->getAttribute('omise_customer_id'),
'card' => $user->getAttribute('omise_card_id'),
'ip' => $request->ip(),
'return_uri' => secure_url('/dashboard'),
], config('omise.public_key'), config('omise.secret_key'));
I am setting capture to false
and a return_uri
and receiving back an authorize_uri
, however navigating to said url, while it does redirect me back to the correct return_uri
, it doesn't send out a webhook request. (I have tried this on the live mode yet, only test mode)
If you could point me in the right direction, that'd be great. Thanks
Hello,
count from OmiseObject work incorrect.
Please add to OmiseCardList.php this function:
/**
*
* @return integer
*/
public function count()
{
if (array_key_exists('data', $this->_values) === true) {
return count($this->_values['data']);
} else {
return 0;
}
}
Also please add following function:
/**
* @param integer $index
*
* @return OmiseCard
*/
public function getCardByIndex($index)
{
if (array_key_exists('data', $this->_values) === true && $index >= 0 && $index < $this->count()) {
return $this->_values['data'][$index];
} else {
return null;
}
}
Hi,
I keep getting this following error when try to install from Composer:
Loading composer repositories with package information
Updating dependencies (including require-dev)
- Installing omise/omise-php (dev-master 7fc6769)
Downloading: 100%
Failed to download omise/omise-php from dist: There was an error extracting the ZIP file, it is either corrupted or using an invalid format.
Now trying to download from source
- Installing omise/omise-php (dev-master 7fc6769)
Cloning 7fc6769c5169892573baea4fab338a7bf1bb7331
7fc6769c5169892573baea4fab338a7bf1bb7331 is gone (history was rewritten?)
[RuntimeException]
Failed to execute git checkout "7fc6769c5169892573baea4fab338a7bf1bb7331" -- && git reset --hard "7fc6769c516989257
3baea4fab338a7bf1bb7331" --
Note: checking out '7fc6769c5169892573baea4fab338a7bf1bb7331'.
You are in 'detached HEAD' state. You can look around, make experimental
changes and commit them, and you can discard any commits you make in this
state without impacting any branches by performing another checkout.
If you want to create a new branch to retain commits you create, you may
do so (now or later) by using -b with the checkout command again. Example:
git checkout -b <new-branch-name>
HEAD is now at 7fc6769... Merge pull request #34 from gitter-badger/gitter-badge
error: unable to create file tests/fixtures/api.omise.co/customers/cust_test_5234fzk37pi2mz0cen3/cards/?limit=1-get
.json (Invalid argument)
fatal: Could not reset index file to revision '7fc6769c5169892573baea4fab338a7bf1bb7331'.
Is there anyway to fix this? My composer version is 1.1.2
when i use OmiseSource::create();
require_once dirname(FILE).'/obj/OmiseObject.php';
require_once dirname(FILE).'/../exception/OmiseExceptions.php';
define('OMISE_PHP_LIB_VERSION', '2.9.0');
define('OMISE_API_URL', 'https://api.omise.co/');
define('OMISE_VAULT_URL', 'https://vault.omise.co/');
class OmiseApiResource extends OmiseObject
you are using api version which does not support this operation
My code
$page = $requests->input('page' , 0 );
$id = '?offset='.($page*15).'&limit=15' ;
$charges = \OmiseCharge::retrieve($id) ;
it seem always sort by created asc .
Thanks
Code like this:
// keys A
$keys[] = [
'omise_public' => 'pkey_test_A',
'omise_secret' => 'skey_test_A',
];
// keys B
$keys[] = [
'omise_public' => 'pkey_test_B',
'omise_secret' => 'skey_test_B',
];
$omiseKey = $keys[0];
OmiseSchedule::retrieve('schd_test_A', $omiseKey['omise_public'], $omiseKey['omise_secret']);
$omiseKey = $keys[1];
OmiseSchedule::retrieve('schd_test_B', $omiseKey['omise_public'], $omiseKey['omise_secret']);
will get
OmiseNotFoundException
schedule schd_test_B was not found
schd_test_A from keys A
schd_test_B from keys B
The issue arises from OmiseSchedule utilizing the singleton pattern to store keys. Consequently, subsequent instances of OmiseSchedule are unable to utilize their own keys for data requests, instead using the keys stored from the previous instance of OmiseSchedule.
Please verify if this is a bug or an issue with my usage.
Seems it's required to call static methods to work with this library, which makes it so hard to unit test. Classes are instantiated through their super classes and so they cannot be DI'd from outside straightforward. Wouldn't be very important for billing related libraries like this to be more test-friendly?
Sorry if I'm wrong, but this library seems quite behind the other ones. It's not updated as often as it could, and the lack of a good implementation tutorial makes it hard to figure out how it works. It would be great if Omise could give more attention to it.
I am working on Laravel project . It throw error about the dash sign on file name 'omise-php' . How can I fix it ??
in the UsersController , you can notice that it hit the line number 6 and thrown error.
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use App\Http\Requests;
use omise\omise-php\lib\Omise;
class UsersController extends Controller
{
// ... others actions
}
in the app.php
// .. other service providers
Laravel\Cashier\CashierServiceProvider::class,
omise\omise-php\lib\Omise::class,
// .. other service providers
Moreover, in naming convention , I have never seen name with dash sign before . I have seen only camelCase , snake_case or PascalCase.
Hey all,
To preface, Laravel has phpunit tests built into the framework, where users can write custom tests for various parts of their application. Ideally, I'd like to use my own custom tests with the Omise Test API, but due to the snippet below, any phpunit tests (including Laravel's) are executed with the executeTest() method and return data saved in the tests/fixtures directory.
// OmiseApiResource.php Lines:134-141
protected function execute($url, $requestMethod, $key, $params = null)
{
// If this class is execute by phpunit > get test mode.
if (preg_match('/phpunit/', $_SERVER['SCRIPT_NAME'])) {
$result = $this->_executeTest($url, $requestMethod, $key, $params);
} else {
$result = $this->_executeCurl($url, $requestMethod, $key, $params);
}
My current workaround is deleting the contents of the fixtures folder before I run my tests, forcing executeTest to go and retrieve the data from the test API source. Is there any way to override this method? Or maybe a way to localize the preg_match
to only the Omise Vendor files?
Some Linux server (Esp. RHEL and CentOS 6.5 till 6.7) are support TLS 1.2 but CURL library is not default to use TLS 1.2 to connect by default.
This result in those server that use omise-php library will trying to connect omise server using outdated TLS 1.1 version which Omise does not support since June 2018.
So I suggest omise-php to update CURL code to set CURLOPT_SSLVERSION to force TLS 1.2. And if system is really not support TLS 1.2 they will emit errors instead of still connect using TLS 1.1.
This similiar fixed already applied in Paypal Braintree-SDK a while ago to force TLS 1.2 when they depecreated old TLS version.
Refer to braintree-php
braintree/braintree_php#160
https://github.com/omise/omise-php/blob/v2.5.0/lib/omise/res/OmiseApiResource.php#L258
Should be:
@return bool|null
How can I retrieve a particular customer? I understand that I can use something like the following:
$customer = OmiseCustomer::retrieve('cust_test_4xtrb759599jsxlhkrb');
But how can I store the customer ID (cust_test_4x...) so that I can reference that customer later on? I am using PHP on the server end and android on the client side.
I need to pass some option to use for make it more secure and fastest.
Example: CURLOPT_INTERFACE
How to pass something like this into curl object ?
Hello,
Can I get one end to end to example in php for accepting credit card details and charging the payment and capturing response back.
Regards,
Tejas
In Omise-PHP, there has one test file that the name is ?limit=1-get.json
which is, Windows OS doesn't support ?
sign on a filename.
It would make an error like below (or similar as below) when you try run composer install
or composer update
Package operations: 1 install, 0 updates, 0 removals
- Installing omise/omise-php (dev-master d68cb6b)
Cloning d68cb6b12e9f7884f47c50f51a2a9b0d53b46e1b from cache
d68cb6b12e9f7884f47c50f51a2a9b0d53b46e1b is gone (history was rewritten?)
Failed to download omise/omise-php from source: Failed to execute git checkout "d68cb6b12e9f7884f47c50f51a2a9b0d53b46e1b" -- && git reset --hard "d68cb6b12e9f7884f47c50f51a2a9b0d53b46e1b" --
Note: checking out 'd68cb6b12e9f7884f47c50f51a2a9b0d53b46e1b'.
You are in 'detached HEAD' state. You can look around, make experimental
changes and commit them, and you can discard any commits you make in this
state without impacting any branches by performing another checkout.
If you want to create a new branch to retain commits you create, you may
do so (now or later) by using -b with the checkout command again. Example:
git checkout -b <new-branch-name>
HEAD is now at d68cb6b... Merge pull request #42 from oaattia/add_phpunit_conf
error: unable to create file tests/fixtures/api.omise.co/customers/cust_test_5234fzk37pi2mz0cen3/cards/?limit=1-get.json: Invalid argument
fatal: Could not reset index file to revision 'd68cb6b12e9f7884f47c50f51a2a9b0d53b46e1b'.
Note: this issue would happen to all windows users.
tested on: Windows 10
For Windows user, I'd recommended that please download Omise-PHP directly from the link below.
https://github.com/omise/omise-php/archive/master.zip
..
Sorry for any inconvenience π .
Nam
As a Linux user that uses case sensitive file system, it will raise the Fatal error: require_once()
Warning: require_once(/vendor/omise/omise-php/lib/omise/res/../Exception/OmiseExceptions.php): failed to open stream: No such file or directory in vendor/omise/omise-php/lib/omise/res/OmiseApiResource.php on line 4 Fatal error: require_once(): Failed opening required '/vendor/omise/omise-php/lib/omise/res/../Exception/OmiseExceptions.php' (include_path='.:') in /vendor/omise/omise-php/lib/omise/res/OmiseApiResource.php on line 4
Payment method working properly on the local server. But it's showing an error on the live server.
Error: OmiseApiResource.php: count(): Parameter must be an array or an object that implements Countable
Please help
https://github.com/omise/omise-php/blob/master/data/ca_certificates.pem
Might be worth checking into https://github.com/paragonie/certainty in the future to keep them up-to-date?
This error means safe_mode or open_basedir are enabled on the host.
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.