Search code examples
javascriptpaypalpaypal-sandboxpaypal-rest-sdkfee

PayPal checkout - platform_fee on order create


I follow this tutorial for enable PayPal on my marketplace : https://developer.paypal.com/docs/business/checkout/set-up-standard-payments/

So, I write this code :

<script src="https://www.paypal.com/sdk/js?client-id=xxxxxxxxxxx"></script>

createOrder: function(data, actions) {
      return actions.order.create({
        purchase_units: [{
          amount: {
            value: '{{ course.price / 100 }}',
            currency: 'EUR'
          },
          payee: {
            merchant_id: '3SBUTQHGTMHWS'
          },
        }],
      });
 },

This one work fine, but when I want add platform_fee, PayPal return a 422 (Unprocessable Entity) :

createOrder: function(data, actions) {
      return actions.order.create({
        purchase_units: [{
          amount: {
            value: '{{ course.price / 100 }}',
            currency: 'EUR'
          },
          payee: {
            merchant_id: '3SBUTQHGTMHWS'
          },
          payment_instruction: {
            disbursement_mode: 'INSTANT',
            platform_fees: [{
              amount: {
                currency_code: 'EUR',
                value: '3'
              }
            }]
          },
        }],
      });
},

How collect platform fee with PayPal Checkout ? Thanks for your help


Solution

  • You can't use platform_fee unless you are an approved PayPal partner