Code Monkey home page Code Monkey logo

omise-php's People

Contributors

aashishgurung avatar adnaoki avatar ajzkk avatar anasnaouchi avatar forfunza avatar fred avatar gitter-badger avatar guzzilar avatar jacstn avatar jakyns avatar jonrandy avatar jun-omise avatar keeratita avatar mazon avatar muthuswamyopn avatar nicodemuz avatar nimid avatar som-m avatar turboza avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

omise-php's Issues

Some PHP hosting with curl can't use omise-lib

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);
        
?>

method OmiseCardList@retrieve use empty key

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

Proposal for 3-0-0 design

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:

  1. Use 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:

  • Keep using static, for ease of use.
  • Use service locator for inversion of control.
  • No define constants, for testability. (One may use class constant, if it's really a constant.)
  • Use pluggable PSR-7 client, for testability, and extendability. (see PSR-7 and httpplug)
  • 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

  • Using static still have the same problem testing plugins that user wants to mock OmiseClient to test their plugin only.
  1. No 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:

  • No static methods, for testability.
  • No define constants, for testability. (One may use class constant, if it's really a constant.)
  • Use pluggable PSR-7 client, for testability, and extendability. (see PSR-7 and httpplug)
  • 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?

Proposal: implement extension for Omnipay

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.

Build your own driver

Namespace

Any purpose about why the library is not using namespace?

[PC] tried to install omise via composer but it shows errors

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 ?

Magento Checkout cart error

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>

Not receiving webhook for charges

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

OmiseCardList::Count() works incorrect

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;
}
}

Error when try to install from Composer

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

api version

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

The bug related to storing keys in a singleton pattern.

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.

Hard to unit test code using this package

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?

This library needs more love

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.

How can I add service provider

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

Error that was thrown
screen shot 2016-07-26 at 20 58 08

Moreover, in naming convention , I have never seen name with dash sign before . I have seen only camelCase , snake_case or PascalCase.

Omise Unit Tests Clashing With Laravel Unit Tests

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?

omise-php should set CURLOPT_SSLVERSION to prevent TLS 1.1 request on some platform.

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

How to store Customer IDs?

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.

Need example on php

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

Error extracting file `?limit=1-get.json` via composer on Windows OS.

Issue

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

Workaround

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

The library raises require_once error on CentOS

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

Live server issue

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

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.