Few questions about subscriptions - paypal

I asked these questions in PayPal's forum but I did not receive any answers. Hopefully, I'll get them here :)
So as I understand if I want to integrate subscriptions I can do it 2 ways
First one is to integrate subscription button using a form, something like this:
<form action="https://www.paypal.com/cgi-bin/webscr" method="post">
<!-- Identify your business so that you can collect the payments. -->
<input type="hidden" name="business" value="businessEmail">
<!-- Specify a Subscribe button. -->
<input type="hidden" name="cmd" value="_xclick-subscriptions">
<!-- Identify the subscription. -->
<input type="hidden" name="item_name" value="Alice's Weekly Digest">
<input type="hidden" name="item_number" value="DIG Weekly">
<!-- Set the terms of the regular subscription. -->
<input type="hidden" name="currency_code" value="USD">
<input type="hidden" name="a3" value="5.00">
<input type="hidden" name="p3" value="1">
<input type="hidden" name="t3" value="M">
<input type="hidden" name="notify_url" value="notify url">
<!-- Set recurring payments until canceled. -->
<input type="hidden" name="src" value="1">
<!-- Display the payment button. -->
<input type="image" name="submit"
src="https://www.paypalobjects.com/en_US/i/btn/btn_subscribe_LG.gif"
alt="Subscribe">
<img alt="" width="1" height="1"
src="https://www.paypalobjects.com/en_US/i/scr/pixel.gif" >
I guess this approach has more drawbacks than benefits, it allows me to create a subscription without creating a product and a plan for the subscription..?
But on the other hand, a user that created a subscription in this way cannot change subscription, only cancellation is possible? Furthermore, I cannot change 'notify_url' if I for example change my website?
The second way to create subscriptions is to use subscriptions API. Create Product and a Plan, as I understand this gives us much more control and removes the drawbacks of the HTML form subscription.
Thank you!

Everything you said is correct, the only thing I would add is that there is also a generator you can use for the old HTML 'Subscribe' and new JS 'PayPal Subscribe' buttons at: https://www.paypal.com/buttons
If you want the old generator to create editable code, you should uncheck the Step 2 option to Save the button at PayPal, then after generating the button click the link above to remove code protection.

Related

Paypal: How does xclick-auto-billing work?

<form action="https://www.paypal.com/cgi-bin/webscr" method="post" target="_blank">
<input type="hidden" name="business" value="dummy#example.com">
<input type="hidden" name="cmd" value="_xclick-auto-billing" /> <!-- _xclick-subscriptions works here -->
<input type="hidden" name="a3" value="1" />
<input type="hidden" name="p3" value="12" />
<input type="hidden" name="t3" value="M" />
<input type="hidden" name="src" value="1" />
<input type="hidden" name="no_note" value="1" />
<input type="submit" name="submit" />
<input type="hidden" value="PP-SubscriptionsBF" name="bn">
</form>
I was trying to find out what the differences are between _xclick-subscriptions and _xclick-auto-billing. Above form works when the cmd value is _xclick-subscriptions. However, when I replace it with _xclick-auto-billing, Paypal returns an error page saying "item amount" is incorrect. I check Paypal's documentation but there isn't much explanation or example about _xclick-auto-billing. So how should I use this cmd and what are the differences?
In general, auto-billing should not be used unless you are able to generate a sample auto billing button via https://www.paypal.com/buttons
When doing so, uncheck the option in section 2 to save the button at PayPal. When viewing the generated code, click the option to remove the code protection. Then you will have sample working HTML that you can adapt to your needs.
If you cannot create such a button, it is because your account does not support it. Subscriptions are much more widely supported and should be used instead, generally speaking.
Instead of the old-style Subscribe button, consider the new Smart Payment Buttons which use plans and products as a base and offer a much more modern checkout experience. See https://www.paypal.com/billing/plans

HTML Variables for Recurring Payments Buttons with a modifier

I'm looking to add a modifier to my PayPal Subscription button. I'd like to modify the subscription cost depending upon how many users the customer enters. Essentially, the subscribe button has a "base cost", with +$xx.xx added to the monthly subscription cost.
For example:
A user wants to create an account on my app with 6 users at $5 per user with a base subscription cost of $10/mo. The monthly cost of that subscription would be $40.
This can be achieved(may not be the most optimal solution)
Go to PayPal button designer
Moreover you are an advanced user in PayPal, you can customize checkout pages for your customers, streamline checkout, and more in this section.
I needed to build the markup as such. Then, using JavaScript I was able to assign the .val() of the item_number, item_name, and a3 fields. Works great!
<form action="https://www.sandbox.paypal.com/cgi-bin/webscr" method="post" target="_top" style="display: inline-block">
<!-- Identify your business so that you can collect the payments. -->
<input type="hidden" name="business" value="...">
<!-- Specify a Subscribe button. -->
<input type="hidden" name="cmd" value="_xclick-subscriptions">
<!-- Identify the subscription. -->
<input type="hidden" name="item_number" monthly_item_name>
<input type="hidden" name="item_name" monthly_item_name>
<!-- Set the terms of the regular subscription. -->
<input type="hidden" name="currency_code" value="USD">
<input type="hidden" name="a3" id="monthly">
<input type="hidden" name="p3" value="1">
<input type="hidden" name="t3" value="M">
<!-- Set recurring payments until canceled. -->
<input type="hidden" name="src" value="1">
<!-- Send the user back here once they've completed payment. -->
<input type="hidden" name="custom" value="<?php echo $_SESSION[ID]; ?>">
<input type="hidden" name="return" value="...">
<input type="hidden" name="rm" value="2">
<input type="submit" name="submit" class="btn btn-inverse" value="Monthly" alt="PayPal - The safer, easier way to pay online!">
<img alt="" border="0" src="https://www.sandbox.paypal.com/en_US/i/scr/pixel.gif" width="1" height="1">
</form>

PayPal custom button with dynamic price

I have a website that offers a service where the price changes dynamically. For instance there are radio buttons and checkboxes that make the final price variate. At the final stage I have an hidden input that contains the final price.
How do I tell PayPal that that is the price to charge? I have tried to follow the documentations on PayPal website but I can't find an answer for this.
How could I dynamically change the values of these inputs but also make sure it's safe?
<form action="https://www.paypal.com/cgi-bin/webscr" method="post">
<!-- Identify your business so that you can collect the payments. -->
<input type="hidden" name="business" value="herschelgomez#xyzzyu.com">
<!-- Specify a Buy Now button. -->
<input type="hidden" name="cmd" value="_xclick">
<!-- Specify details about the item that buyers will purchase. -->
<input type="hidden" name="item_name" value="Hot Sauce-12 oz. Bottle">
<input type="hidden" name="amount" value="5.95">
<input type="hidden" name="currency_code" value="USD">
<!-- Prompt buyers to enter their desired quantities. -->
<input type="hidden" name="undefined_quantity" value="1">
<!-- Display the payment button. -->
<input type="image" name="submit" border="0"
src="https://www.paypalobjects.com/en_US/i/btn/btn_buynow_LG.gif"
alt="PayPal - The safer, easier way to pay online">
<img alt="" border="0" width="1" height="1"
src="https://www.paypalobjects.com/en_US/i/scr/pixel.gif" >
</form>
Any help would be much appreciated, I'm really stuck on this.
Thanks,
Jeff

Is it possible to POST advanced HTML variables for SUBSCRIBE buttons in the list of parameters submitted to PayPal?

I'm using the PayPal standard SUBSCRIBE button. The HTML looks something like the code-snippet below. The issue is that it appears FORM parameters a1/p1/t1, a3/p3/t3, src/sra, and any other advanced HTML variables for the PayPal SUBSCRIBE button cannot be overridden. That is, they remain set to the values you configured in the standard-button configuration on PayPal's website.
QUESTION: how can I programmatically override the advanced PayPal subscription parameters from my website? Is this even possible? Thanks.
<form accept-charset="UTF-8" action="https://www.paypal.com/cgi-bin/webscr" class="signup_company" id="signup_company" method="post">
<input type="hidden" name="cmd" value="_s-xclick" />
<input type="hidden" name="hosted_button_id" value="MY_PAYPAL_BUTTON_ID" />
<input type="hidden" name="currency_code" value="USD" />
<!-- First two months of subscription are free. -->
<input type="hidden" name="a1" value="0" />
<input type="hidden" name="p1" value="2" />
<input type="hidden" name="t1" value="M" />
<!-- Recurring subscription payments. -->
<input type="hidden" name="a3" value="29.95" />
<input type="hidden" name="p3" value="1" />
<input type="hidden" name="t3" value="M" />
<input type="hidden" name="src" value="1" />
<input type="hidden" name="sra" value="1" />
<!-- Pass-through variable sent to paypal; it is set in javascript before the submit. -->
<input type="hidden" name="custom" value="Evergreen::::foo#baz.com::::4" />
<input type="image" src="https://www.paypalobjects.com/en_US/i/btn/btn_subscribe_SM.gif"
border="0" name="submit" alt="PayPal - The safer, easier way to pay online!"
onclick="$(#signup_company).submit();" />
<img alt="" border="0" src="https://www.paypalobjects.com/en_US/i/scr/pixel.gif" width="1" height="1" />
</form>
After speaking with a PayPal tech, here is the how to proceed with the PayPal Standard Subscribe button, if you want maximal programmatic control over the HTML form variables:
Do not save your button as a hosted button at PayPal. If you do, then overriding whatever price tiers that you have configured and saved at PayPal cannot be overridden.
Do not encrypt your button. This means that when you create your Subscribe button, you should do two things: (a) use your e-mail address in the HTML form-post, rather than some merchant ID from PayPal; and (b) unprotect / unencrypt the HTML form variables generated during the button-create step.
Once you copy-and-paste the PayPal-generated HTML into your webapp, you can then rely on JavaScript event-handler to dynamically adjust the HTML form-parameters that determine the pricing / duration / etc of your subscription.

PayPal Checkout Buttons and Custom Variables

I have created a rather simple photo gallery that I wish to apply PayPal Checkout buttons. The basics are simple enough, but what I want to do is to at least pre-populate the named fields as part of the button or pass variables contained in each individual page through to the cart.
Each page contains a picture ID, date, and title. I would like to be able to pass this data along so that when someone clicks "Add to Cart", the data is already there. Right now the only way I can see the buttons working is creating custom fields and having the customer copy and paste the data themselves, kind of a pain.
If I could figure this one thing out PayPal checkout might be worth while. Has anyone here ever done this?
You need something like this? I got it out of the PayPal docs awhile back. I'm using it in a production app now. Please test before using though :)
<form target="paypal" action="https://www.paypal.com/cgi-bin/webscr" method="post" style="margin:4px 0px 0px 4px;">
<input type="image" src="<ADD_TO_CART_BUTTON>.jpg" border="0" name="submit" alt="Add this item to your shopping cart">
<img alt="" border="0" src="https://www.paypal.com/en_US/i/scr/pixel.gif" width="1" height="1">
<input type="hidden" name="add" value="1">
<input type="hidden" name="cmd" value="_cart">
<input type="hidden" name="business" value="<YOUR_PAYPAL_EMAIL>">
<input type="hidden" name="item_name" value="<THE_ITEM_NAME>">
<input type="hidden" name="item_number" value="<THE_ITEM_NUMBER_SKU_OR_WHATEVER>">
<input type="hidden" name="amount" value="<HOW_MUCH_IT_COSTS>">
<input type="hidden" name="no_shipping" value="1">
<input type="hidden" name="cn" value="<CUSTOM_TEXT_FOR_THE_BUYER_TO_LEAVE_YOU_SPECIAL_INSTRUCTIONS>">
<input type="hidden" name="currency_code" value="USD">
<input type="hidden" name="lc" value="US">
<input type="hidden" name="bn" value="PP-ShopCartBF">
<input type="hidden" name="address_override" value="1">
<input type="hidden" name="business_cs_email" value="<YOUR_PAYPAL_EMAIL>">
<input type="hidden" name="return" value="<WHERE_TO_TAKE_THE_USER_AFTER_PURCHASE_LIKE_thankyou.html>">
<input type="hidden" name="notify_url" value="<IF_YOU_PROCESS_ORDERS_THROUGH_YOUR_SITE_THE_CALLBACK_URL_GOES_HERE>">
</form>
You'll need one of these for each item you're selling.
Signup at http://sandbox.paypal.com and start working in their sandbox to try this out.
Also check out http://www.x.com and http://www.paypal-labs.com. They've been doing some cool stuff with checkouts.
Also check out using the "custom" PayPal variable, which you can use to pass any information you want to PayPal and get it back when the transaction completes.