Generating Credentials
First you will need to head to https://developer.paypal.com/developer/applications/create and create a new PayPal app using your PayPal Developer login.
Once you have created your app, change the environment to 'Live'.
For demo purpose, all screenshots below are from Sandbox, but in live this is the same.
Next copy Client ID
Now under Client ID you need to copy secret key, for that click on the Show and you will see the token there.
You can generate new key if you donโt have any.
Now click the Make Credentials button, and you will get a new โBasicโ token, copy it toghether with name โBasicโ.โ
Insert tokens in Plugin settings.
Now paste โBasicโ token in the plugin settings in Authorization (header).
Below in the Client ID paste obviously, your Client ID.
โThere are a few things to understand to complete a recurring payment plan, the flow should follow these actions:
Create a Plan
After using the create a plan action, you will be returned a 'Plan ID', The plan is now created but is not active and cannot be used yet.
Activate The Plan
You will need to now run the action to activate the plan, here you will need the 'Plan ID' that was returned when you created it.
Note: You can also mark a plan as 'INACTIVE' by changing the state parameter to 'INACTIVE' & reactivate by using the value 'ACTIVE'
Create an Agreement
Once again you will need the same 'Plan ID' along with the customized details of your customer to create the agreement. In this action's response you will receive two links, the first is the 'REDIRECT' link & the second is the 'EXECUTE' link.
Before we can execute the agreement and start charging the customer we need the customer to sign into PayPal and setup a payment method / shipping details and finally agree to the plan/agreement you have now made.
To do this we use the 'PayPal Agreement Link' action, providing the 'REDIRECT' link as the URL. After the user has agreed they will be redirected back to your app with the added URL parameter 'token'. On page load you will need to get data from URL to obtain the token value, then use this as the required ID when you run the Execute Agreement action.
Note: The new ID you are returned is the required ID to cancel a plan for this user so youi can either store it with the user or find it using the Get Agreements action.
Important: While using various calls you will notice more instances of URL's being returned to perform actions with regards to this plan/agreement. You can use these by placing them in the Use PayPal Action Link action in the plugin.
Update 06.20.2019
Added 3 new Actions:
- Paypal Payments - Create A Product NEW API
- Paypal Payments - Create A Plan NEW API
- Paypal Payments - Create A Subscription NEW API
Description and how to use
1. Create a Product - First of all you need to create a product. For that you will have to select product type and product category.
There can be 3 types of products :
PHYSICAL, DIGITAL and SERVICE (write them as is with uppercase)
You will find details of all available categories and product types in PayPal documentation:
PayPal Documentation, Create Productโ
2. Create a Plan - Next you will have to create a plan for that product, you can create various plans for one product. You can add different billing cycles types. Also here you need to specify the price and the currency.
Read more about it in PayPal documentation:
PayPal Documentation, Billing Plansโ
3. Create a subscription - Now you can subscribe users. Here you can choose what kind of subscription to create, for example with shipment if this is a physical product or without if it is digital.
There are 3 types of shipment:
NO_SHIPPING, SET_PROVIDED_ADDRESS and GET_FROM_FILE (write them as is with uppercase )
Read more details about it in Paypal documentation:
PayPal Documentation, Crate Subscription
Next you have to approve this new subscription by activating it. For that use action Use PayPal Action Link.In action link field insert: https://api.sandbox.paypal.com/v1/billing/subscriptions/SUBSCRIPTION_ID_HERE/activate/โ
In content type field write:
application/json
If you want to cancel a subscription, first of all, this subscription must be activated so you can cancel it. You can cancel it using same action Use PayPal Action Link.Where in action link field must be this URL: https://api.sandbox.paypal.com/v1/billing/subscriptions/SUBSCRIPTION_ID_HERE/cancelโIn content type field write:
application/json