- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello Sir,
Can we take payment from user's account without his/her consent, i want to get consent only once after that can i take direct payment from his/her paypal account as we do from Credit-Card??
Below is the documentation on Billing Agreements:
https://developer.paypal.com/docs/api/quickstart/create-billing-agreement/
Below is the API and sample code:
https://developer.paypal.com/docs/api/payments.billing-agreements/v1/
Above links only works for fixed and regular billing, But in my case user can take the goods from my shop on rent many time and the rental amount will be different according to the rental time. in this case how can i create the billing agreement?
I want to do all these things in JAVA, Please provide me any help as soon as possible.
Thanks
Solved! Go to Solution.
- Labels:
-
API
-
Recurring Payments
-
REST
-
SDK
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello,
Here is the correct information on creating a reference transaction and billing it. The ID you are using is for a recurring payment and not a billing agreement so you would receive that error message.
First you have to create the billing agreement:
Post to this endpoint: https://api.sandbox.paypal.com/v1/billing-agreements/agreement-tokens
{
"description": "Billing Agreement",
"shipping_address":
{
"line1": "1350 North First Street",
"city": "San Jose",
"state": "CA",
"postal_code": "95112",
"country_code": "US",
"recipient_name": "John Doe"
},
"payer":
{
"payment_method": "PAYPAL"
},
"plan":
{
"type": "MERCHANT_INITIATED_BILLING",
"merchant_preferences":
{
"return_url": "https://example.com/return",
"cancel_url": "https://example.com/cancel",
"notify_url": "https://example.com/notify",
"accepted_pymt_type": "INSTANT",
"skip_shipping_address": false,
"immutable_shipping_address": true
}
}
}
Customer then agrees to the billing agreement.
Then post to this endpoint the token_id is the Billing Agreement that was created and agreed to by the customer.
https://api.sandbox.paypal.com/v1/billing-agreements/agreements
{
"token_id": "BA-3NH886535B517561H"
}
Now you can run a Reference Transaction with the initial consent from the customer. You will use the Billing Agreement id to be able to charge the buyer account.
Not the billing agreement in this example is an example only, you will get your own billing agreement from the first step.
Post to this endpoint: https://api.sandbox.paypal.com/v1/payments/payment
{
"intent": "sale",
"payer":
{
"payment_method": "PAYPAL",
"funding_instruments": [
{
"billing":
{
"billing_agreement_id": "B-9ME198576H649014R"
}
}]
},
"transactions": [
{
"amount":
{
"currency": "USD",
"total": "10.00"
},
"description": "Payment transaction.",
"custom": "Payment custom field.",
"note_to_payee": "Note to payee field.",
"invoice_number": "GDAGDS5754YEKS",
"item_list":
{
"items": [
{
"sku": "skuitemNo1",
"name": "ItemNo1",
"description": "The item description.",
"quantity": "1",
"price": "10.00",
"currency": "USD",
"tax": "0",
"url": "https://example.com/"
}]
}
}],
"redirect_urls":
{
"return_url": "https://example.com/return",
"cancel_url": "https://example.com/cancel"
}
}
Please note that the example billing agreement in this post is for example purposes. If you use the billing agreement in this example you will receive an error because the billing agreement is for example purposes.
Thanks,
Jennifer
PayPal
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello,
Thank you for posting to the PayPal Merchant Technical Support Community.
Reference Transactions may be the best option for you. If you create a billing agreement
after the initial agreement from the PayPal Account holder (subscriber), you can bill them different amounts via API call.
Your Sandbox Account will need to be approved for this feature. If you comment your sandbox merchant id I can ensure that Reference Transactions in Sandbox is enabled.
Thank you,
Jennifer
PayPal
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Marcel,
I've ensured that the functionality is enabled for the Sandbox account.
Note : This functionality can be enabled on sandbox accounts without prior review, but within our production environment this functionality does have to be requested and a review process occurs to determine if your account is eligible. Just so you're aware.
Thanks !
Jennifer
PayPal
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello Sir,
I think my sandbox account not enabled for reference transactions, because when i calling REST api for payment from agreement-ID i am getting below exception:
ERROR: Response code: 403 Error response: {"name":"PERMISSION_DENIED","message":"No permission for the requested operation","information_link":"https://developer.paypal.com/docs/api/payments/#errors","debug_id":"f2e72bae06508","code":"PERMISSIO..."}
Payment-ERROR: {
"intent": "sale",
"payer": {
"payment_method": "paypal",
"funding_instruments": [
{
"billing": {
"billing_agreement_id": "I-DEAG403061HU"
}
}
]
},
"transactions": [
{
"amount": {
"currency": "USD",
"total": "0.23"
},
"description": "Test payment by billing agreement"
}
],
"redirect_urls": {
"return_url": "http://localhost:8080/RechargeNow/paypal/payment-success",
"cancel_url": "http://localhost:8080/RechargeNow/paypal/payment-cancel"
}
}
Can you tell me please how can i resolve it?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello,
Here is the correct information on creating a reference transaction and billing it. The ID you are using is for a recurring payment and not a billing agreement so you would receive that error message.
First you have to create the billing agreement:
Post to this endpoint: https://api.sandbox.paypal.com/v1/billing-agreements/agreement-tokens
{
"description": "Billing Agreement",
"shipping_address":
{
"line1": "1350 North First Street",
"city": "San Jose",
"state": "CA",
"postal_code": "95112",
"country_code": "US",
"recipient_name": "John Doe"
},
"payer":
{
"payment_method": "PAYPAL"
},
"plan":
{
"type": "MERCHANT_INITIATED_BILLING",
"merchant_preferences":
{
"return_url": "https://example.com/return",
"cancel_url": "https://example.com/cancel",
"notify_url": "https://example.com/notify",
"accepted_pymt_type": "INSTANT",
"skip_shipping_address": false,
"immutable_shipping_address": true
}
}
}
Customer then agrees to the billing agreement.
Then post to this endpoint the token_id is the Billing Agreement that was created and agreed to by the customer.
https://api.sandbox.paypal.com/v1/billing-agreements/agreements
{
"token_id": "BA-3NH886535B517561H"
}
Now you can run a Reference Transaction with the initial consent from the customer. You will use the Billing Agreement id to be able to charge the buyer account.
Not the billing agreement in this example is an example only, you will get your own billing agreement from the first step.
Post to this endpoint: https://api.sandbox.paypal.com/v1/payments/payment
{
"intent": "sale",
"payer":
{
"payment_method": "PAYPAL",
"funding_instruments": [
{
"billing":
{
"billing_agreement_id": "B-9ME198576H649014R"
}
}]
},
"transactions": [
{
"amount":
{
"currency": "USD",
"total": "10.00"
},
"description": "Payment transaction.",
"custom": "Payment custom field.",
"note_to_payee": "Note to payee field.",
"invoice_number": "GDAGDS5754YEKS",
"item_list":
{
"items": [
{
"sku": "skuitemNo1",
"name": "ItemNo1",
"description": "The item description.",
"quantity": "1",
"price": "10.00",
"currency": "USD",
"tax": "0",
"url": "https://example.com/"
}]
}
}],
"redirect_urls":
{
"return_url": "https://example.com/return",
"cancel_url": "https://example.com/cancel"
}
}
Please note that the example billing agreement in this post is for example purposes. If you use the billing agreement in this example you will receive an error because the billing agreement is for example purposes.
Thanks,
Jennifer
PayPal
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello Sir,
Thanks for your help, your response is helpfull, I have below link that has the details to do same thing, link is:
But this link has the code in CURL, I need same code in JAVA.
Can you help me please how can i use this code in JAVA, Or you can provide a link where this sample code exists in JAVA.
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello,
This page has code samples in Java: https://developer.paypal.com/docs/api/quickstart/create-billing-agreement/
Thank you,
Jennifer
PayPal
Haven't Found your Answer?
It happens. Hit the "Login to Ask the community" button to create a question for the PayPal community.