Paypal Recurring Payments without One-Time Purchase - php

I am attempting to set up a Paypal Recurring Profile, but I keep getting the error code 10525: "This transaction cannot be processed. The amount to be charged is zero." I only want to start the recurring billing, rather than charge them a one time payment amount and then the recurring billing on top of that. ($13 every month or $135 annually are the choices).
From the paypal knowledge (https://www.paypal-knowledge.com/infocenter/index?page=content&id=FAQ1441&actp=LIST) I found:
"Use BillingType=RecurringPayments/MerchantInitiatedBilling instead for creating a Recurring Profile/Billing Agreement ID with no dollar amount."
However, I have already done so.
Also, in the paypal api(https://developer.paypal.com/docs/classic/api/merchant/SetExpressCheckout_API_Operation_NVP/) I found:
"Set this field to 0 if the transaction does not include a one-time purchase such as when you set up a billing agreement for a recurring payment that is not immediately charged. When the field is set to 0, purchase-specific fields are ignored."
But it is set to "0", so I'm not sure what to do there.
Here is my debug list:
2017-11-08 19:39:28 - PayPal Express debug (Call data): {
"METHOD":"SetExpressCheckout",
"MAXAMT":0,
"RETURNURL":"***",
"CANCELURL":"***",
"REQCONFIRMSHIPPING":0,
"NOSHIPPING":1,
"LOCALECODE":"EN",
"LANDINGPAGE":"Login",
"HDRIMG":"***",
"PAYFLOWCOLOR":"FFFFFF",
"CHANNELTYPE":"Merchant",
"ALLOWNOTE":"1",
"PAYMENTREQUEST_0_SHIPPINGAMT":"",
"PAYMENTREQUEST_0_CURRENCYCODE":"USD",
"PAYMENTREQUEST_0_PAYMENTACTION":"Sale",
"L_PAYMENTREQUEST_0_DESC0":"Journal Inside Pages:Unlined, Journal Theme:Mom",
"L_PAYMENTREQUEST_0_NAME0":"The Gratitude Project",
"L_PAYMENTREQUEST_0_NUMBER0":"JNL103",
"L_PAYMENTREQUEST_0_AMT0":0,
"L_PAYMENTREQUEST_0_QTY0":"1",
"L_PAYMENTREQUEST_0_ITEMURL0":"***",
"L_PAYMENTREQUEST_0_ITEMLENGTHVALUE0":"8.00000000",
"L_PAYMENTREQUEST_0_ITEMLENGTHUNIT0":"in",
"L_PAYMENTREQUEST_0_ITEMWIDTHVALUE0":"10.00000000",
"L_PAYMENTREQUEST_0_ITEMWIDTHUNIT0":"in",
"L_PAYMENTREQUEST_0_ITEMHEIGHTVALUE0":"0.00000000",
"L_PAYMENTREQUEST_0_ITEMHEIGHTUNIT0":"in",
"PAYMENTREQUEST_0_ITEMAMT":"0.00",
"PAYMENTREQUEST_0_AMT":0,
"L_BILLINGTYPE0":"RecurringPayments",
"L_BILLINGAGREEMENTDESCRIPTION0":"1 USD every 1 day"}
2017-11-08 19:39:29 - PayPal Express debug (Result):
"TOKEN=EC%2d67C48949S6014741D&TIMESTAMP=2017%2d11%2d08T19%3a39%3a29Z&CORRELATIONID=a278368193eb9&ACK=Success&VERSION=109%2e0&BUILD=40710629"
2017-11-08 19:39:47 - PayPal Express debug (Call data):
{"METHOD":"GetExpressCheckoutDetails",
"TOKEN":"EC-67C48949S6014741D"}
2017-11-08 19:39:48 - PayPal Express debug (Result): "TOKEN=***"
2017-11-08 19:39:48 - PayPal Express debug (Call data):
{"TOKEN":"EC-67C48949S6014741D",
"PAYERID":"8CKXXNF3MR26N",
"METHOD":"DoExpressCheckoutPayment",
"PAYMENTREQUEST_0_NOTIFYURL":"***",
"RETURNFMFDETAILS":1,
"PAYMENTREQUEST_0_SHIPPINGAMT":"",
"PAYMENTREQUEST_0_CURRENCYCODE":"USD",
"PAYMENTREQUEST_0_PAYMENTACTION":"Sale",
"L_PAYMENTREQUEST_0_DESC0":"Journal Inside Pages:Unlined, Journal Theme:Mom",
"L_PAYMENTREQUEST_0_NAME0":"The Gratitude Project",
"L_PAYMENTREQUEST_0_NUMBER0":"JNL103",
"L_PAYMENTREQUEST_0_AMT0":0,
"L_PAYMENTREQUEST_0_QTY0":"1",
"L_PAYMENTREQUEST_0_ITEMURL0":"***",
"L_PAYMENTREQUEST_0_ITEMLENGTHVALUE0":"8.00000000",
"L_PAYMENTREQUEST_0_ITEMLENGTHUNIT0":"in",
"L_PAYMENTREQUEST_0_ITEMWIDTHVALUE0":"10.00000000",
"L_PAYMENTREQUEST_0_ITEMWIDTHUNIT0":"in",
"L_PAYMENTREQUEST_0_ITEMHEIGHTVALUE0":"0.00000000",
"L_PAYMENTREQUEST_0_ITEMHEIGHTUNIT0":"in",
"PAYMENTREQUEST_0_ITEMAMT":"0.00",
"PAYMENTREQUEST_0_AMT":0,
"L_BILLINGTYPE0":"RecurringPayments",
"L_BILLINGAGREEMENTDESCRIPTION0":"1 USD every 1 day"}
If I do, however, set the PAYMENTREQUEST_0_AMT to "13.00", for instance, the call goes in correctly. However the customer would double pay for their first month (total of $26). I could set a trial period for "0", but that would only fix the monthly subscription, not the annual subscription.
I am using Paypal Express (Sandbox) with Opencart 2.3.0.2
This problem is known via Opencart, but no one has fixed it. So I was attempting to fix it myself. I have not used Paypal API before so I'm not sure where to look.

"Set this field to 0 if the transaction does not include a one-time purchase...." in the link
https://developer.paypal.com/docs/classic/api/merchant/SetExpressCheckout_API_Operation_NVP/ means that "n" in the parameter "PAYMENTREQUEST_n_AMT" is set to "0" instead of you set total amount into "0".
So, "MAXAMT" and "L_PAYMENTREQUEST_0_AMT0" cannot be "0 but should be more than 0 to match your total amount.
You are request to firstly call SetExpressCheckout API (BillingType=RecurringPayments), and got response with EC token and use it in CreateRecurringPaymentsProfile API
https://developer.paypal.com/docs/classic/api/merchant/CreateRecurringPaymentsProfile_API_Operation_NVP/

Related

Recurring Paypal payment with dynamic amount in Standard paypal method

I have one simple PayPal Standard HTML form with 3 textbox and one button .
textbox 1 : <Amount pay now>
textbox 2 : <Out standing Amount pay on specific date>
textbox 3 : <recurring payment date>
Now when user clicks on a button, it redirects to PayPal for payment process as I have used PayPal standard method.
I want the amount to be processed from textbox1 and another amount should process automatically on a specific date.
Can someone please help out me to achieve this ?
srt - Recurring times
src - 1 //Subscription payments recur.
sra - 1. Reattempt failed recurring payments before canceling.
a3 - Regular subscription price.
p3 - Subscription duration. Specify an integer value
t3 - Regular subscription units of duration.
Valid range for p3 is 1 to 90 in D. similarly M, etc
business - your business email
item_name - order id / descripiton of item sold
currency_code - USD / INR
This is the reference URL
https://developer.paypal.com/docs/classic/paypal-payments-standard/integration-guide/Appx_websitestandard_htmlvariables/#recurring-payment-variables
https://developer.paypal.com/docs/classic/paypal-payments-standard/integration-guide/html_example_subscribe/#product-options-as-text-boxes
Ex. This sample HTML code illustrates a basic Subscribe button with these features:
https://developer.paypal.com/docs/classic/paypal-payments-standard/integration-guide/html_example_subscribe/#basic-subscribe-button
No trial periods. A subscription price of $5.00 USD. A monthly
billing cycle. The subscription ends only when the merchant or
subscriber cancels it.
This isn't a simple bit of programming.
Why don't you use a third party like Stripe to handle this for you? It's built in and will be a lot easier for you to setup and you could focus on creating a decent custom dashboard where you could pull via the API of Stripe customer information and opportunity to change/cancel their subscription?

Recurring payment with stripe with varying amount

I am working on a project where the subscriber can limit his subscription on monthly basis.
As an example below
Lets say i have 5 products A - Euro 40 ,B - Euro 40, C - Euro 40, D- Euro 40,E - Euro 40
Month 1 - A + B + C + D -> First order. I am using stripe ideal to generate the payment for 4 products. Total Euro 160
Month 2 - Subscriber cancels product D subscription. So now the recursive payment must work only for the price of A+B+C. So now the total comes Euro 120
Month 3 - Subscriber cancels product C subscription. So now the recursive payment must work only for the price of A+B. So now the total comes Euro 80
Month 4 - Subscriber cancels product A + B subscription. So the subscription should be cancelled.
Work done till now:
The stripe ideal is only one time payment. In this case, i can use SEPA but will get the update 14-16 working days.
https://stripe.com/docs/sources/ideal/recurring
I am using wordpress and initiating the ideal payment programatically (not using plugin) using Stripe PHP library.
What is the alternative i can go for iDEAL?
Is it possible, if i collect the card details of the customer and charge the card on recurring basis without user authorization.
Hope i made my question clear.
I'm admittedly not particularly learned in this world, but Stripe does have some guidance here:
https://stripe.com/docs/sources/ideal/recurring
Basically, you have to turn it into a SEPA Direct Debit source, then every month inform your customer of what they're going to owe. Hopefully that's helpful!

Stripe Partial refund and full refund issue

Here is what i am trying to do. Total is $120
1 : First i did a Partial Refund with this charge ID ch_1AfNOwAWa9KSz110***** .
\Stripe\Refund::create(array(
"charge" => 'ch_1AfNOwAWa9KSz*******',
"amount" => 60 * 100,
));
2 : After that i want to refund full the amount that left in this chargeID ch_1AfNOwAWa9KSz110*********
\Stripe\Refund::create(array(
"charge" => 'ch_1AfNOwAWa9KSz1********'
));
I am getting error Charge ch_1AfNOwAWa9KSz110********* has already been refunded.
What should i do first i did partial and after full refund in stripe.?
According to the docs:
You can optionally refund only part of a charge. You can do so
multiple times, until the entire charge has been refunded.
So it seems you can create a refund without an amount (a full refund) only if you have not refunded already (partially), otherwise you need to specify the amount explicitly.
It would be great, though, if Stripe accepted refunding without an amount specified even after a partial refund, meaning to refund the remaining amount.
Based on the docs, I think you want to use the update refund endpoint instead of the create refund endpoint for the second call.

paypal express checkout set paypal fee additional

I have integrate paypal express checkout in our website. as i know and get information from paypal documentation.
Need to set Amount parameter in request input and paypal deduct fee based on amount, but i want paypal add fee additional on amount.
Example :
Product amount : $100.00;
Paypal deduct fee 2.9% on $100.00 but i want add aditional 2.9% on main amount, like :
Amount = 100.00
Fee = 2.9%
Than Total amount is = $100.00 + 2.9% = $102.90
means i want paypal automatically set his fee on checkout page and charge to user.
Can anyone help me.
Thanks in Advance.
If you want to add that fee on to your order you'll need to do so prior to sending the user to PayPal, or you could also do it on your review page after the user is returned from PayPal.
Most people just add this to their cart as a "handling fee" or whatever you want to call it. If you want to be more accurate you should use the 2.9% + .30 formula.

Paypal NVP API Recurring Profile Upgrade Profile Charge surplus amount at a time and Next Billing Cycle

I tried using simple CreateRecurringProfile and UpdateRecurringPaymentsProfile of Paypal NVP apis.
I have confusion If i can achieve my goal or not Please suggest me the solutions
Case 1:
Silver Package = $20
Gold Package = $100
My Custome created Recurring Payment with Billing Cycle of $20 Per month for 6 months on Jan 1st For silver Subscription Plan.
Later on Customer come back on Feb 2nd and updates his subscription package from silver to gold subscription at that time i want to update to subscription plan as All next billing cycle will charge to $100 from $20 but when he upgrades he/she must be charges $80 (i.e sur plus amount) because remaining $20 is paid on Feb 1st's Bill.
Thanks in Advance
Please suggest me some solutions.
In such a case, You can cancel Recurring payment Profile, And create new Profile for $100 as Recurring amount And $80 as Initial Amount ( INITAMT as given in documentation of CreateRecurringPaymentsProfile)

Categories