简体   繁体   中英

At PayPal, how can I create a subscription, where the half of the amount go to merchant?

I create a product, with product id a plan, and with a plan a subscription, but I don't know where should I add the merchant id or email.

Here is the code, how I create a subscription now:

        //create product
        $http = Http::withHeaders([
            'Authorization' => 'Basic '.$headerForBasicAuth,
            'Content-Type' => 'application/json'
        ]);
        $body = [
            'name' => "example sub",
            'type' => "DIGITAL",
        ];
        $response = $http->post($this->paypalModel->getBasePath().'/v1/catalogs/products', $body)->body();
        $product = json_decode($response);

        if($data['price']==1){
            $subPrice = $subscription->monthly_fee;
            $interval = "MONTH";
        }else{
            $subPrice = $subscription->annual_fee;
            $interval = "YEAR";
        }
        //create plan
        $body = [
            'billing_cycles' => [
                [
                    'frequency' => [
                        "interval_unit" => $interval,
                        "interval_count" => 1
                    ],
                    "tenure_type" => "REGULAR",
                    "sequence" => 1,
                    "total_cycles" => 0,
                    "pricing_scheme" => [
                        "fixed_price" => [
                            "value" => $subPrice,
                            "currency_code" => "USD",
                        ]
                    ]
                ],
            ],
            'name' => "example plan",
            'payment_preferences' => [
                "auto_bill_outstanding" => true,
                "payment_failure_threshold" => 0
            ],
            'product_id' => $product->id,
        ];
        $response = $http->post($this->paypalModel->getBasePath().'/v1/billing/plans', $body)->body();
        $plan = json_decode($response);
        //create subscription
        $body = [
            'plan_id' => $plan->id,
            'application_context' => [
                'cancel_url' => 'http://laravel-paypal-example.test',
                'return_url' => 'http://laravel-paypal-example.test',
                'shipping_preference' => 'NO_SHIPPING',
            ]
        ];
        $response = $http->post($this->paypalModel->getBasePath().'/v1/billing/subscriptions', $body)->body();
        $sub = json_decode($response);

I want to add somewhere the merchant id, and the sum or the percentage of amount, but I don't know where should I do this.

You can't. PayPal Subscriptions will send money to the merchant's account, and the most straightforward way to integrate them for a merchant is with that merchant's client ID and secret. The plans must also be created in the merchant's account. The full payment amount will go to the merchant's account.

To set up / some type of process recurring payment, where money is paid directly to a merchant's account plus and some fee goes to you, since PayPal Subscriptions is not suited to that you'll need a combination of:

  1. You being an approved PayPal partner who can use the (non-Subscriptions) orders API partner_fee after onboarding new merchants.
  2. Some type of integration that lets you bill payers at dates and times and amounts of your choosing, which goes by a number of names: reference transactions / billing agreements (not subscription billing agreements) / future payments, and vaulting. For PayPal the account permission is still usually referred to as reference transactions, though the API may be different.

To be approved for (1) and to be approved for (2), contact PayPal. You won't be able to complete this type of integration without its approval and support.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM