Với Bina Pay Standard và Express, bạn có thể dễ dàng và an toàn nhận thanh toán trực tuyến từ khách hàng.

Bina Pay Tài liệu Cổng thanh toán Express.

Người thanh toán

Nếu người thanh toán muốn sử dụng Bina Pay, hãy đặt người thanh toán là Bina Pay. (Các phương thức khác như PayPal, Stripe, Coin Payments chưa khả dụng).

                        
                            //Payer Object 
                            $payer = new Payer(); 
                            $payer->setPaymentMethod('PayMoney'); //preferably, your system name, example - PayMoney
                        
                    
Số tiền

Chỉ định số tiền và tiền tệ.

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

Đây là tài nguyên Giao dịch cần đặt đối tượng số tiền.

                        
                            //Transaction Object
                            $trans = new Transaction();
                            $trans->setAmount($amountIns);
                        
                    
URL chuyển hướng

Đặt URL để người mua chuyển hướng sau khi giao dịch hoàn tất hoặc hủy.

                        
                            //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/
                        
                    
Thanh toán

Đây là tài nguyên thanh toán cần đặt Payer, Amount, RedirectUrls và thông tin Merchant (Client ID và Client Secret). Sau khi khởi tạo, gọi phương thức create để tạo URL chuyển hướng. Người dùng cần chuyển hướng đến URL này để hoàn tất giao dịch.

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

Các bước chạy mã này trên thiết bị của bạn:

Bước 1 :

Nhấp tải gói

Bước 2 :

Bây giờ, đi đến php-sdk/src/PayMoney/Rest/Connection.php, sau đó thay đổi BASE_URL value to your domain name(i.e: If the domain is - 'your-domain.com' then, define( 'BASE_URL' , 'http://your-domain.com/' ) )

                        
Mã ví dụ
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);

Hướng dẫn tùy chọn

Nếu không thấy thay đổi sau khi cấu hình và giải nén SDK, hãy vào thư mục SDK và chạy lệnh sau::-

  • Composer clear-cache
  • Composer install
  • Composer dump-autoload