nguoingulanh/paypal-panel 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

nguoingulanh/paypal-panel

Composer 安装命令:

composer require nguoingulanh/paypal-panel

包简介

Payment paypal ...

README 文档

README

  • Get from paypal checkout sdk

https://developer.paypal.com/api/rest/authentication/
https://developer.paypal.com/docs/api/orders/v2/

Configuration

To get started, you should publish the config/paypal-panel.php config file with:

php artisan vendor:publish --provider="PaypalPanel\ServiceProvider"

setup construct:

    public $client;

    public function __construct()
    {
        $paypalConfigs = config('paypal-panel');

        $env = new SandboxEnvironment($paypalConfigs['client_id'], $paypalConfigs['secret']);
        $mode = 'sandbox';

        //live
        // $env = new ProductionEnvironment($paypalConfigs['client_id'], $paypalConfigs['secret']);
        // $mode = 'live';

        $this->environment = $env;
        $this->client = new PayPalHttpClient($this->environment);
    }

Code:

use PaypalPanel\Order\OrdersCreateRequest;
$request = new OrdersCreateRequest();
$request->prefer('return=representation');
$request->body = [
                     "intent" => "CAPTURE",
                     "purchase_units" => [[
                         "reference_id" => "test_ref_id1",
                         "amount" => [
                             "value" => "100.00",
                             "currency_code" => "USD"
                         ]
                     ]],
                     "application_context" => [
                          "cancel_url" => "https://example.com/cancel",
                          "return_url" => "https://example.com/return"
                     ] 
                 ];

try {
    // Call API with your client and get a response for your call
    $response = $client->execute($request);
    
    // If call returns body in response, you can get the deserialized version from the result attribute of the response
    print_r($response);
}catch (HttpException $ex) {
    echo $ex->statusCode;
    print_r($ex->getMessage());
}

统计信息

  • 总下载量: 4
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2023-03-27