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

Issue

I created a product with Product ID as Plan and Plan as Subscription, but I don’t know where to add the Merchant ID or Email.

Here’s the code to create the subscription:

 // create a 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";
        }other than that{
            $subPrice = $subscription->annual_fee;
            $interval = "year";
        }
        // create plan
        $body = [
            'Billing Cycle' => [
                [
                    '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' => "Sample Plan",
            'Payment settings' => [
                "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 would like to add the merchant id and amount total or percentage somewhere, but I don’t know where to do this.

Solution

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 for recurring payment, where money is paid directly to a merchant’s account plus and some fee goes to you, as 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 when 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.

Answered By – Preston PHX

Answer Checked By – Katrina (Easybugfix Volunteer)

Leave a Reply

(*) Required, Your email will not be published