如何设置多方付款(船上卖家)

How to Set Up Multiparty Payments (Onboard Sellers)

我正在尝试实施 Paypal 多方支付,这样我就可以连接卖家和买家,然后我从他们那里收取 x% 的平台使用费 例如。 Fiverr,Upwork,自由职业者, 所以首先卖家连接他的帐户然后他们可以销售服务并通过贝宝接受付款但我不知道如何将贝宝帐户连接到我的应用程序

我正在使用 laravel 9 和 srmklive/laravel-paypal 软件包

这是我的代码

Route::get('https://api-m.sandbox.paypal.com/v2/customer/partner-referrals', function () {
      $provider = new PayPalClient;
      $provider->setApiCredentials(config('paypal'));
      $paypalToken = $provider->getAccessToken();
      
      $partner = $provider->createPartnerReferral([
        "operations" => [
          [
            "operation" => "API_INTEGRATION",
            "api_integration_preference" => [
              "rest_api_integration" => [
                "integration_method" => "PAYPAL",
                "integration_type" => "FIRST_PARTY",
                "first_party_details" => [
                  "features" => [
                    "PAYMENT",
                    "REFUND"
                  ],
                  "seller_nonce" => uniqid()
                ]
              ]
            ]
          ]
        ],
        "products" => [
          "EXPRESS_CHECKOUT"
        ],
        "legal_consents" => [
          [
            "type" => "SHARE_DATA_CONSENT",
            "granted" => true
          ]
        ]
      ]);
      dd($partner);
    })

这是输出

^ array:2 [▼
  "type" => "error"
  "message" => "{"operations":[{"operation":"API_INTEGRATION","api_integration_preference":{"rest_api_integration":{"integration_method":"PAYPAL","integration_type":"FIRST_PARTY","first_party_details":{"features":["PAYMENT","REFUND"],"seller_nonce":"623a1fcec9be3"}}}}],"products":["EXPRESS_CHECKOUT"],"legal_consents":[{"type":"SHARE_DATA_CONSENT","granted":true}]} {"name":"INVALID_REQUEST","message":"Request is not well-formed, syntactically incorrect, or violates schema.","debug_id":"f64fe0ec63213","information_link":"","details":[{"issue":"INVALID_STRING_LENGTH","description":"The length of a field value should not be shorter than 44 characters.","field":"/operations/0/api_integration_preference/rest_api_integration/first_party_details/seller_nonce","location":"body"}],"links":[]} ◀"
]

提前致谢

Route::get('https://api-m.sandbox.paypal.com/v2/customer/partner-referrals', function () {
      $provider = new PayPalClient;
      $provider->setApiCredentials(config('paypal'));
      $paypalToken = $provider->getAccessToken();
      
      $partner = $provider->createPartnerReferral([
        "operations" => [
          [
            "operation" => "API_INTEGRATION",
            "api_integration_preference" => [
              "rest_api_integration" => [
                "integration_method" => "PAYPAL",
                "integration_type" => "FIRST_PARTY",
                "first_party_details" => [
                  "features" => [
                    "PAYMENT",
                    "REFUND"
                  ],
                  "seller_nonce" => uniqid()
                ]
              ]
            ]
          ]
        ],
        "products" => [
          "EXPRESS_CHECKOUT"
        ],
        "legal_consents" => [
          [
            "type" => "SHARE_DATA_CONSENT",
            "granted" => true
          ]
        ]
      ]);
      dd($partner);
    })

这是输出

^ array:2 [▼
  "type" => "error"
  "message" => "{"operations":[{"operation":"API_INTEGRATION","api_integration_preference":{"rest_api_integration":{"integration_method":"PAYPAL","integration_type":"FIRST_PARTY","first_party_details":{"features":["PAYMENT","REFUND"],"seller_nonce":"623a1fcec9be3"}}}}],"products":["EXPRESS_CHECKOUT"],"legal_consents":[{"type":"SHARE_DATA_CONSENT","granted":true}]} {"name":"INVALID_REQUEST","message":"Request is not well-formed, syntactically incorrect, or violates schema.","debug_id":"f64fe0ec63213","information_link":"","details":[{"issue":"INVALID_STRING_LENGTH","description":"The length of a field value should not be shorter than 44 characters.","field":"/operations/0/api_integration_preference/rest_api_integration/first_party_details/seller_nonce","location":"body"}],"links":[]} ◀"
]

"details":[{"issue":"INVALID_STRING_LENGTH","description":"The length of a field value should not be shorter than 44 characters.","field":"/operations/0/api_integration_preference/rest_api_integration/first_party_details/seller_nonce

错误消息的详细信息很有用,是吗?该字段记录在 the API reference 中。您也可以省略它。

经过一番搜索,我发现问题是我的 seller_nonce 字段少于 44 个字符,因此请确保您的 seller_nounce 超过 44 个字符。另外,请确保您已选中 付款后登机

seller_nonce => uniqid(Str::random(40), true)