Express Checkout as guest

tkflick
Contributor
Contributor

I got a call a couple of weeks to to rewrite a site for someone who's previous developer passed away. The original site was written in PHP, which I don't know, and used a wordpress shopping cart to check out with PayPal.

 

I've written a custom .Net shopping cart in C# that is database driven, so the site owner can control his items for sale. I total up the sale on the site, and make a call to PayPal to "Pay Now".  This is working perfectly. The only drawback is that doing it this way, the customer does not get the link to pay without creating a PayPal account.

 

I considered the Pay Now hosted button with $0.00 as the price, but this scenario asks the customer to enter the price, and I need to supply the price that I've totaled up with shipping included.  I've also considered creating a hosted button for each item, but I'm using a custom shopping cart, and I've been unable to find any documentation on passing multiple hosted button id's to PayPal. In addition, if the website owner uses the admin tool I wrote to add a new item for sale, this new item doesn't have the custom hosted button available.

 

Is there a work-around that will allow me to perform an express-like checkout but allow the customer to pay with a credit or debit card if they have no paypal account?  This doesn't seem much different from a one item checkout with a hosted button, and that scenario allows checkout as guest.

Login to Me Too
2 REPLIES 2

Snow-Cat
Advisor
Advisor

You may want to visit the Merchant Support Community for help (there's other developers and PayPal Techs there.)

Login to Me Too

tkflick
Contributor
Contributor

After 3 days, I finally found a link  that led me to another link that helped me figure this out. I basically had to create a PayPal Express Checkout app.

In case anyone else has a similar issue, here are the steps I followed: 

 

1) I logged into my PayPal account and went here to create a paypal app: https://developer.paypal.com/developer/applications/create
I saved the sandbox and production Client ID values that were created, I needed them later

 

2) Then I added the checkout.js script to my checkout page: <script src="https://www.paypalobjects.com/api/checkout.js"></script>

PayPal recommends referencing their script and not downloading a local copy to your project.

 

3) Next, I went here to help create the javascript I would need for my checkout page: https://developer.paypal.com/demo/checkout/#/pattern/client
I used the Client Side REST, and pasted it into my checkout page. I updated the sandbox and production client id values with the
client id's I created in step 1 above.

 

4) I added a hidden variable on the page:  <input type="hidden" runat="server" id="amount" name="amount" value="7.99" />
that I set from the code behind with the grand total including shipping.

 

5) Then instead of the hard coded amount in the generated javascript, I grabbed the amount value from the hidden input object: amount: { total: amount.value, currency: 'USD' }

Now, when the customer lands on my checkout page, I display a pretty datagrid/table showing their order details and the total with shipping. When they click the "checkout with paypal" button, paypal performs an express checkout for me with the grand total, and I'm done. 

Login to Me Too

Haven't Found your Answer?

It happens. Hit the "Login to Ask the community" button to create a question for the PayPal community.