使用 I Super Pay 標準和Express,您可以輕鬆安全地從客戶那裡獲得在線付款。

I Super Pay 快速支付网关文档。

付款人

如果付款人想使用 I Super Pay,將付款人設置為 I Super Pay。

                        
                            //Payer Object 
                            $payer = new Payer(); 
                            $payer->setPaymentMethod('PayMoney'); //preferably, your system name, example - PayMoney
                        
                    
数量

指定付款金额和货币。

                        
                            //Amount Object 
                            $amountIns = new Amount(); 
                            $amountIns->setTotal(20)->setCurrency('USD'); //must give a valid currency code and must exist in merchant wallet list 
                        
                    
交易

它是必须设置数量对象的事务资源。

                        
                            //Transaction Object
                            $trans = new Transaction();
                            $trans->setAmount($amountIns);
                        
                    
重定向网址

设置买家在交易完成或取消后应重定向的网址。

                        
                            //RedirectUrls Object
                            $urls = new RedirectUrls();
                            $urls->setSuccessUrl('http://your-merchant-domain.com/example-success.php') //success url - the merchant domain page, to redirect after successful payment, see sample example-success.php file in  sdk root, example - http://techvill.net/PayMoney_sdk/example-success.php
                            ->setCancelUrl('http://your-merchant-domain.com/');//cancel url - the merchant domain page, to redirect after cancellation of payment, example - http://techvill.net/PayMoney_sdk/
                        
                    
支付

它是一种支付资源,必须设置所有 Payer、Amount、RedirectUrls 和商户凭证(客户端 ID 和客户端密钥)。初始化为支付对象后,需要调用create方法。它将生成一个重定向 URL。用户必须重定向到此 URL 才能完成交易。

                        
                            //Payment Object
                            $payment = new Payment();
                            $payment->setCredentials([ //client id & client secret, see merchants->setting(gear icon)
                            'client_id' => 'place your client id here',  //must provide correct client id of an express merchant
                            'client_secret' => 'place your client secret here' //must provide correct client secret of an express merchant
                            ])->setRedirectUrls($urls)
                            ->setPayer($payer) 
                            ->setTransaction($trans);
                            
                            try {
                            $payment->create(); //create payment
                            header("Location: ".$payment->getApprovedUrl()); //checkout url
                            } catch (Exception $ex) { 
                            print $ex; 
                            exit; }
                        
                    

有关如何在您的设备上运行此代码的几个步骤:

第一名 :

点击下载包

第二名 :

现在,去 php-sdk/src/PayMoney/Rest/Connection.php, 然后改变 BASE_URL value to your domain name(i.e: If the domain is - 'your-domain.com' then, define( 'BASE_URL' , 'http://your-domain.com/' ) )

                        
示例代码
require 'vendor/autoload.php'; //if you want to change the namespace/path from 'PayMoney' - lines[1-5] - //to your desired name, i.e. (use PayMoney\Api\Amount; //to use MyDomain\Api\Amount;), then you must change the folders name that holds the API classes //as well as change the property 'PayMoney' in (autoload->psr-0) of (php-sdk/composer.json) file to your //desired name and run "composer dump-autoload" command from sdk root use PayMoney\Api\Payer; use PayMoney\Api\Amount; use PayMoney\Api\Transaction; use PayMoney\Api\RedirectUrls; use PayMoney\Api\Payment; //Payer Object $payer = new Payer(); $payer->setPaymentMethod('PayMoney'); //preferably, your system name, example - PayMoney //Amount Object $amountIns = new Amount(); $amountIns->setTotal(20)->setCurrency('USD'); //must give a valid currency code and must exist in merchant wallet list //Transaction Object $trans = new Transaction(); $trans->setAmount($amountIns);

可选说明

如果您在配置和解压 SDK 后没有看到更改,请转到您的 SDK 根目录并运行以下命令:-

  • Composer 清除缓存
  • 作曲家安装
  • Composer 转储自动加载