I am using the following code to send a payment request to PayPal's API (the $field array in the $paypal class is used to build a POST request). This code works fine.
$paypal = new paypal_class;
$paypal->add_field('business', $store_email);
$paypal->add_field('return', $script_location.'?action=success&order_id='.$order_id);
$paypal->add_field('cancel_return', $script_location.'?action=cancel');
$paypal->add_field('notify_url', $script_location.'?action=ipn');
$paypal->add_field('item_name_1', strip_tags(str_replace("'","",$_POST["description"])));
$paypal->add_field('amount_1', $amount);
$paypal->add_field('item_number_1', $item_id);
$paypal->add_field('quantity_1', '1');
$paypal->add_field('custom', $_SERVER['REMOTE_ADDR']);
$paypal->add_field('upload', 1);
$paypal->add_field('cmd', '_cart');
$paypal->add_field('txn_type', 'cart');
$paypal->add_field('num_cart_items', 1);
$paypal->add_field('payment_gross', $amount);
$paypal->add_field('currency_code', strip_tags(str_replace("'","",$_POST["currency"])));
$paypal->submit_paypal_post(); // submit the fields to paypal
Now, let's say the $amount I'm sending is $199. This amount will be charged correctly using the code above. Now I want to charge $29 per year in addition to the initial $199. Can I modify the code above (sending some extra fields presumably) to accomplish this?
I've been looking through the docs and I've seen some options for recurring billing but can't find one for exactly what I'm looking for - which is an initial payment of Amount X and then recurring payments of Amount Y.
You can offer a trial period of any amount including 0. The Trial period is the initial payment and after the trial period is over then you can setup the actual subscription amount, and start the billing on a specific date.
Here is the documentation for Express Checkout:
Express Checkout Recurring with Trial Period
&TRIALBILLINGPERIOD=Month #Period of time in one trial period
&TRIALBILLINGFREQUENCY=1 #Frequency of charges, if any, during the trial period
&TRIALTOTALBILLINGCYCLES=1 #Length of trial period
&TRIALAMT=0 #Payment amount (can be 0) during the trial period
&CURRENCYCODE=USD #The currency, e.g. US dollars
Here is the documentation for direct Recurring Payments
Trial Period for Direct Recurring Payments
It looks like you're working with Payments Standard. Can you confirm that?
If so, the answer pp_MSI_Jenn gave isn't going to apply. That said, I would recommend you switch to Express Checkout if you're comfortable with PHP class (which apparently you are.) This class library will make Express Checkout very simple for you.
You'll be working with the following API's.
SetExpressCheckout
GetExpressCheckoutDetails
CreateRecurringPaymentsProfile
Since you mentioned that you want to charge a one-time amount of $199 and then $29/year after that, you actually don't need to mess with a trial period. Instead, you'll just use the INITAMT parameter in the CRPP request to process the $199. Then you'll use the regular AMT, BILLINGPERIOD, BILLINGFREQUENCY, etc. to setup the $29/year, but you'll set the PROFILESTARTDATE to be 1 year from the current date. That way the first $29 payment won't happen for 1 year, but you'll get the $199 right away when the profile is created.
If you'd rather stick with Payments Standard, then you actually could utilize the trial period as a work-around the way pp_MSI_Jenn mentioned doing with Express Checkout. You would set the trial period for 1 year and use the $199 amount for that period, and then set the regular period to $29/year.
For more details on that look at the Sandard Varaibles list, specifically the recurring payments section.
Related
Requirement:
We want to have a base subscription which is X/month, done via recurring payments, and give clients the ability to choose extra "add-ons" as they please. An "add-on" will be Y/Month and should last the remainder of the base subscription. For example, the base subscription is 10/month and feature X is extra 5/month and feature Y is an extra 7/month. I choose to have the base subscription with feature X and Y so my total monthly payment for a year will be 22/month. Now, if I chose only the base subscription for the first 6 months and want to start using feature X for the final 6 months of my subscription, the final 6 months should be 15/month opposed to the previous 10/month. In further terms, add-on features subscription should last the duration of the base subscription.
Is there a simple way to do this via the PayPal API?
Actual recurring payments profiles (setup with Standard or Express Checkout) have a limit on how much you can raise the amount of a profile. You can only raise it by 20% every 180 days. If you create a recurring payments profile with Payments Pro, though, then there is no such limit and you can change the amount at any time to whatever you need. I wouldn't recommend going without EC, though, as lots of people prefer to pay with PayPal.
What you could do, though, instead of using the recurring payments APIs would be to use billing agreements / reference transactions. This way you'd save the billing agreement / auth ID in your database and then you can use the DoReferenceTransaction API to process any variable amount you need to at any time.
So in that case you would basically be building your own recurring payments system where you'll save the "next payment date" in your database, and then you'll have an automated script run each day to process all of the payments that are due that day via a reference transaction.
Reference transactions work with Payments Pro, too, so if you're using that everything would still work the same.
Since you're working with PHP I'd recommend taking a look at my class library for PayPal. It will make all of these API calls very simple for you.
I would like to know, if Paypal supports multiple stage recurring payment ?
For instance, can we have payment structure something like this :
$10/month for 3 months
$20/month for 6 months
$30/month thereafter.
The payment is billed every month. I could not find any help in the Paypal developer community, so I am starting to think, such a payment structure is not supported at all.
P.S : It is not a follow-up question to my previous one.
The actual Recurring Payments API only allows for a one time payment that happens when the profile is created, and then you can do a trial amount and period, and then the actual amount and period. In your case you could just do a $30 one time for the first 3 months, then $20/mo trial period, and then $30/mo until canceled.
Alternatively, you could setup your own recurring payments system using the Preapproval API and then you wouldn't have any limitations (outside of the profiles themselves) on how or when you charge different amounts.
I know this maybe a duplicate but due to the overwhelming amount of paypal APIs I am having a hard time finding a GOOD answer to my question.
I need to create variable monthly billing per user in PHP. The idea is that a user could sell a number of items with a total sum of sales at the end of the month p. So the billing would be something of the extent MY_PERCENTAGE_FEE * p. The user would then be sent an invoice, and a would be automatically billed via paypal for that amount.
Now, it would be SUPER great if this could be done by creating reoccurring billing and updating the amount at the end of the month. Is that possible? If not what would be the next best way to go?
If you're creating recurring profiles with Payments Pro you can adjust those without any limits. Unfortunately, with Express Checkout you're limited to raising the amount by only 20% every 180 days, so that doesn't normally work out very well. You have a few options of how to get around that.
1) Utilize billing agreements with Express Checkout and Reference Transactions. This would allow you to run an authorization (or an original sale of some sort) for a payer and then from that point on you can use that transaction ID from the original transaction along with a new amount in the DoReferenceTransaction API. Reference Transactions area available with Payments Pro by default, but if you want to use them with Express Checkout you'll need to get that specifically enabled on your account.
2) Use the Preapproval API, which is part of the Adaptive Payments platform. This is similar to reference transactions except that you can create preapproved rules by which you can bill your payers at any time without further approval. This would allow you to process payments for them at any time you need to and pull variable amounts accordingly.
3) Use the Pay API, which is also part of Adaptive Payments, with a split payment (parallel or chained) which would allow you to take your cut in real-time without the need to track balances and submit variable recurring payments. Each time one of your customers is paid for their product/service, you would immediately be paid your share.
I am currently creating a paypal payment with recurring support. I want it
in such a way that there is an initial payment made.
Example :
30$ - initial payment
10$ - recurring monthly payment
The initial payment is charge upon checkout. I'm using the html standard
integration process.
Is it possible?
Using paypal NVP API for PHP, you can send the initial payment to paypal like this.
$nvpstr="&AMT=10&CREDITCARDTYPE=$creditCardType&ACCT=$creditCardNumber&EXPDATE=". $padDateMonth.$expDateYear."&CVV2=$cvv2Number&FIRSTNAME=$firstName&LASTNAME=$lastName&STREET=$address1&CITY=$city&STATE=$state".
"&ZIP=$zip&COUNTRYCODE=US&CURRENCYCODE=$currencyCode&PROFILESTARTDATE=$profileStartDate&DESC=$profileDesc&BILLINGPERIOD=$billingPeriod&BILLINGFREQUENCY=$billingFrequency&TOTALBILLINGCYCLES=$totalBillingCycles&INITAMT=30.00";
$resArray=hash_call("CreateRecurringPaymentsProfile",$nvpstr);
parameter INITAMT specifies the initial payment amount
Yes, this is possible with Website Payments Standard (the 'HTML standard integration process' I assume you use). Simply include a trial period within the subscription, and start charging X days from when subscriptions ends.
See the subscription variables here.
I too switched from website payment's pro to html integration and unfortunately initial amount option is not available in HTML version. If you can switch website payments pro and use API then you can have the option of initial amount (I had to switch because API is not allowed on Israel paypal accounts) otherwise the only option you have in HTML is trial periods.
But on the below link the INTAMT is not proper way to deduct initial payment
Paypal recrurring payments
So please put your thoughts.
The situation is like this,
I have three kind of user registration on my site
$20/month
$30/month
$40/month
now, suppose a user registers with $30 amount and takes the 2nd registration...
next 2 months his $30 per month were deducted as per the recurring payment of paypal...working fine .:)
Now, he wants to upgrade to $40 i.e 3rd membership , so from next month his amount deduction should be $40... How to update paypal for this change in amount..
I DON'T WANT TO GO TO PAYPAL'S SITE FOR THIS...
Is there any API for this purpose.......
Any help would be appreciated....
First off, Paypal's API is not a simple or easy thing to use, but what you're asking can be done. It is simply a matter of canceling the existing 'recurring payment profile' via the API, and starting another recurring payment that ends at the same time.
The API methods themselves change depending on which system you are using. At my company, we use Paypal Website Payments Pro. This has a specific set of functions to perform actions. Without knowing which system you use, however, we can't give any further advice.
The below link shows a number of the methods for the different Paypal API's. Do your research, and try to ask specific questions. :)
https://cms.paypal.com/us/cgi-bin/?cmd=_render-content&content_ID=developer/howto_api_reference
Daniel Moniz
I was able to do this, but first, this caveat from PayPal should be noted:
Note: For recurring payments with Express Checkout, the payment amount can be increased by no more than 20% every 180 days (starting when the profile is created).
Since I'm not using Express Checkout, POSTing this worked for me to change an amount from $75 to $200 (the credentials are fake):
TRXTYPE=R&TENDER=C&PARTNER=PayPal&VENDOR=Acme&USER=Acme&PWD=a1b2c3d4
&ACTION=M&AMT=200.00&ORIGPROFILEID=RP0000001234
The other caveat is that this is only one of I-don't-know-how-many APIs and I-don't-know-how-many-types-of-accounts (in this case Payflow) that PayPal has, and I don't know if something similar works for all of them. The above code is actually copied almost verbatim (credentials and amount changed) from https://developer.paypal.com/docs/classic/payflow/recurring-billing/.