Send unique id to google checkout - google-checkout

I'd like to use google checkout to charge for subscriptions to my website. In order to efficiently process orders, I need to collect the purchaser's email address or another unique id for that order, so that later I can activate their account.
Is there a way to programmatically associate an id that I can generate at runtime with an order placed in google checkout?
If possible, I'd like to do this just by generating different html for the "buy now" button. If necessary, I can use the API.
Update: I see various mentions of merchant-item-id, and when I create a button with Google's tools I can set that field statically. If there were a dynamic way to set merchant-item-id, that would be perfect. Any solutions like that?

Look in to the notification API:
http://code.google.com/apis/checkout/developer/Google_Checkout_HTML_API_Notification_API.html
Changing the code of the buy now button wouldn't actually notify you if the order was completed - there'd be no way to determine if a user just loaded the buy now page, completed the payment, or if the payment was declined. With the notification api you can instantly activate the subscription only when payment is received. Of course, you have to write the script to receive the notification...
The only other option I see if changing the continue_url to somehow change the thank you page to include the id, but this is easy to fake.

The answer seems trivial now. Just throw:
<input name="shopping-cart.items.item-1.merchant-item-id" type="hidden" value="11235" />
into your BuyNow button code (or whatever form you're using to submit) with 11235 being any value you like.

Related

Paypal recurring payment for custom billing cycle

I am working on a website in PHP that needs custom cycle for paypal recurring payment. Ex: a customer wants to receive a product in every 15 days. So paypal should process billing in every 15 days for the customer. Others can ask for the same in 30 days, and so on.
I also need the payment status to be updated. I guess paypal will send some data when a recurring payment is done. Not getting clear instructions on implementing the recurring. What I am getting is to create the recurring payment button from paypal account.
Can anyone help me on this?
Assuming the number of days is chosen at checkout time and never changes for that particular customer's custom billing cycle...
Quick solution:
You can generate a "Subscribe" button via http://www.paypal.com/buttons for a certain number of days, say 15 days. In "Step 2", uncheck the option to save the button at PayPal. Once you have generated the code, click the option to remove the code protection.
This will give you plain HTML, and "15" will be one of the variables there. Possible variables are documented at https://developer.paypal.com/docs/classic/paypal-payments-standard/integration-guide/Appx_websitestandard_htmlvariables/
So, you can change that hidden input to be of type "text" -- or alternatively to still be hidden but set by your javascript or server-side code, and have a dynamic button for X number of days. The image can also be changed to one of your own, of course.
More involved solution: integrate one of PayPal's recurring subscription APIs, which will accomplish much the same thing as that HTML button. This seems to be the newest API: https://developer.paypal.com/docs/subscriptions/
(The API and the HTML button are separate products , and not interchangeable in terms of how you manage existing recurring profiles later on, so if you need a full-fledged API, best integrate it from day 1 rather than using the HTML button)
If the first assumption does not hold, and you need customers to be able to adjust the billing cycle at a later date after checkout, then things get more complicated.
As far as getting payment status updates, you can integrate PayPal's webhook service: https://developer.paypal.com/docs/integration/direct/webhooks/
There is also an older IPN service that is similar in function

Mailchimp API - send update notification for existing subscribers

I have the following workflow using the Mailchimp API:
User is signing up on a form and uses the button "I want to opt in for the newsletter"
The User is posted to the Mailchimp API with status pending and receives a double-opt-in email
The User clicks on the confirm button and his status is changing to ```subscribed``
Now there is a chance, the user is coming back to another form in my app, but clicks again on the button "I want to opt in for the newsletter"
Now I have two possibilities:
My script is checking weather the user already exists on the list, in this case -> ignore and do nothing
My script triggers a Mailchimp "Update Details" Mailing which asks the user to update its details
1st case is easily doable with the Mailchimp API.
2nd case I know is possible via Mailchimp Widgets but I have not found anything in the API docu to trigger this update mailing.
I know about the different status: https://developer.mailchimp.com/documentation/mailchimp/guides/manage-subscribers-with-the-mailchimp-api/ but nothing is reflecting this particular case ("User already subscribed").
I'd like to know how I can do that and how I can trigger an "update details" mailing via the API.
As far as I know and from what it sounds like you've seen as well there isn't a pre-built option or endpoint in place to trigger MC's update profile email.
But because this version of their email is essentially just a link to the existing subscribers list profile, one of the following workarounds might be worth a shot.
1) Use their API automation workflow option to send existing subscribers an email with their update profile link using the merge tag:
*|UPDATE_PROFILE|*
Doc on that Automation API endpoint: https://developer.mailchimp.com/documentation/mailchimp/reference/automations/emails/queue/
Doc on update profile: http://kb.mailchimp.com/campaigns/design/add-an-update-profile-link
Alternatively if you'd like to try and serve subscribers their profile link right on your form after your script check in #2 that to could be done after retrieving:
the subscribers unique_email_id
From: https://developer.mailchimp.com/documentation/mailchimp/reference/lists/members/#read-get_lists_list_id_members_subscriber_hash
and appending that hashed id to end of the lists specific Update profile URL as the value for e=
Which would lead them to their existing pre-filled update profile form:
E.g: http://mailchimp.{USX}.list-manage.com/profile?u=839fhdd4dd38abf344924fa&id=f29uundc48d&e={unique_email_id}
Your list specific URL sans the e= value can be obtained from using the update profile merge tag in their Campaign builder and using preview or sending yourself a test email.

Is it possible to add a 'pending' subscriber to Mailchimp via the API?

Here's what I'd like to do:
User completes sign up form on my app
My app sends the input data (email address, name, etc) to Mailchimp via the API, but with a status of 'pending'
My app sends an email to the user asking them to confirm their email address (essentially emulating the Mailchimp confirmation email)
User clicks link in confirmation email, which takes them back to a confirmation page in my app
My app updates the user's status in Mailchimp to 'subscribed' via the API
Essentially, I want to emulate Mailchimps standard confirmation process, but sending the emails from my own app.
The part that I don't know how to do (or don't know if it's possible) is the part where I add a new subscriber with a status of 'pending'.
Here's some further info that's not strictly relevant but may be of interest...
Why don't I just use the standard Mailchimp confirmation email?
The confirmation email needs to contain extra info, unique to each user, that Mailchimp will not have access to.
Why don't I collect all the data locally and then send it all to Mailchimp once the user has confirmed their email address?
For reasons I won't go into, the number and type of required fields will be unknown. At the point when the sign up form is displayed, I will request the list of fields from Mailchimp and display the necessary fields. It is possible that, between the time when the user initially completes the form and the time when the user confirms via email, the required fields will have been changed. If I try to submit the previously collected data to Mailchimp after the required fields have been changed, it will cause an error.
So I need to collect and submit all data to Mailchimp at the same time. And then simply 'switch on' that user in Mailchimp once (s)he has confirmed.
I hope I've provided enough info. If not, happy to provide more or clarify any points.
Thanks!
The internal "pending" status is not able to be managed manually like that. You can subscribe them using double opt-in and then later force them onto the "subscribed" list, but you can't stop them from getting MailChimp's own confirmation email.
One possible work-around would be to add an interest group or merge field that is populated by your system once you've confirmed the email address. You'd then create a saved segment for only confirmed users and make sure you only ever send to that segment and never the whole list.
Another possibility, if you use API v3.0 (which is currently only in beta), is to add them to your list as unsubscribed and then switch their status to "subscribed" once you've confirmed them. If you do this, be very careful that you're not re-subscribing users who unsubscribed or you could wind up in trouble.
This workflow is definitely 100% possible in the current (V3) of the API. Just set the "status" field on a member to "pending" and then to "subscribed".

Send a 'click' to Google Analytics from ruby

I'm building an app with some 'mail tracking' feature and want to notify google analytics about a click in a link from ruby.
I've already changed all external links from email to go to my server to be redirected, so I know what and when the user clicked.
I want to send this click just knowing the 'UA-XXXXX' and the clicked url.
Is there a way? Or the best solution is to render a html page and with JS send the click event?
UPDATE: Ok, I've found gabba but don't know how to send an 'click' event.
Generally its better to use the JS api, since it has access to all of the other data that analytics tracks, like the visitor browser/os/geoip and can tie all that to a 'visit'.
If you are embedding links in emails, you might consider using the source/medium/campaign flags in the links.
http://support.google.com/analytics/bin/answer.py?hl=en&answer=1033867
So technically its not tracking the 'clicks' as an event, more like tracking the fact that the user came to your site from that particular email. You could use a separate campaign label if you wanted the individual click granularity. (If, for example you had the same url in the email more than once and you wanted to know whether they clicked the first or second one in the email)

What is an accepted way to submit form data to sites like paypal?

I'm setting up a website that uses paypal to process payments.
The easiest way to implement the checkout form would be to create an HTML form that submits directly to paypal, sending the order details and redirecting the user to paypal in order to finalize the transaction.
However, there is a security vulnerability with this process. The client could edit the information submitted to paypal, such as changing the price of the checkout to $0.00.
What is an accepted way to handle this type of situation? Is it to submit the form back to my server, then do some processing in PHP, then submit verified data to paypal and redirect the user to paypal? Is this possible?
Thanks!
There are two main ways to handle this issue.
The first is somewhat like what you outline: You send the filled in form to PayPal, and provide a callback-url. When PayPal has processed the payment, they will call your provided url, and you can check whether or not the information given in that call is the same as what you provided. For this to work, you need to store the information in the meantime, like in a database. You will then only give access to the product after the validation has happened.
You can also encrypt the information you send to PayPal, making it practically impossible to alter information in your form.
See https://www.x.com/developers/paypal for details.

Resources