Pass Custom Variable to PayPal server via IPN Message and Response - iphone

I had successfully integrated Paypal with my iPhone application, but I got stuck over passing the Custom variable via SOAP to Pay pal using IPN Message.
Has anyone pass the Custom Variable to Pay-pal Server????I am making an application for a restaurant,user can make payment using Pay-pal server.
I need to pass the Custom variable (i.e Bucket Id) to Paypal. I get this Bucket Id via web service which I call before making request to pay pal server. Now I need to pass this Bucket Id as Custom Variable to Paypal Server so that it returns the Message Notification.
Note: - I need to make payment using this Bucket Id.
At last when I will get this Notification , I will again call web-service which is going to update the server database of client.
I used this reference:
https://cms.paypal.com/cms_content/US/en_US/files/developer/IPNGuide.pdf
Any kind of help is welcomed.....
Please suggest me with some sample code as I had googled alot about this or other reference....

I find out the solution. But for Android, but I think it can be applied to iOS:
PayPalPayment payment = new PayPalPayment();
payment.setCurrencyType("USD");
payment.setSubtotal(3.30);
payment.setRecipient("test_seller11#gmail.com");
payment.setPaymentType(PayPal.PAYMENT_TYPE_GOODS);
payment.setCustomID("7982");
payment.setIpnUrl("some.site.com/PaymentCallback");
payment.setDescription("Buy 300 coins");
So this is the solution, to pass your extra params to IPN, and to get them back in callback on your server:
payment.setCustomID("7982");

Related

Paypal PDT integration in .Net with Blazor

We are trying to integrate Paypal subscriptions with .Net web application done in Blazor.
We have created a button that allows the customer to enrol to a subscription defined in paypal business.
The customer can do the "payment" or "enrolment" successfully and it returns back to our web application with the specific URL that we defined.
This return URL contains just one parameter, called "token".
The problem is that we want to be syncronize paypal payments with our own control of payments implemented by us in the application, so we need to receive some other information in this URL like the transactionID or some identifier that we can use later to link with one customer.
We have configured paypal to support PDT.
When the customer finishes the enrolment to the subscription, the token returned to the URL i passed to our backend and with this, we try to get the some extra information.
We do a post to the url "https://www.sandbox.paypal.com/cgi-bin/webscr" passing as parameter the token that we received back from the transaction and our token as merchant in paypal.
Theorically, when doing this call, we should receive a response that contains "SUCCESS" and then, we should be able to extract some parameters configured in the PDT of paypal.
But, unfortunately, we always receive "FAIL"
Do you have any idea why does it happens?
Thank you very much in advance.
PDT returns are not reliable, as a payment can complete and the client return never happen for any number of reasons -- so PDT should never be used for anything important, and thus there is no reason for a well designed integration to bother attempting to verify them. Contents of a PDT is suitable for information purposes (display summary of success) to a customer only -- if you are doing anything else with PDT data, rethink your integration..
If you must continue such a very old checkout method that uses PDT as part of its process, a service such as IPN or Webhooks should be added on to receive a somewhat more reliable, direct post from PayPal with the payment information.
The best solution however, is to do neither of those things -- since adding on asynchronous notifications to an existing very old integration has its own disadvantages. Instead, discard your current integration completely as it's already about 4 generations old / 20 years old, and implement a new, current PayPal Checkout integration from scratch:
Follow the PayPal Checkout integration guide and make 2 routes (url paths) on your server, one for 'Create Order' and one for 'Capture Order'. Both of these routes should return only JSON data (no HTML or text). Inside the 2nd route, when the capture API is successful you should verify the amount was correct and store its resulting payment details in your database (particularly purchase_units[0].payments.captures[0].id, which is the PayPal transaction ID) and perform any necessary business logic (such as sending confirmation emails or reserving product) immediately before forwarding your return JSON to the frontend caller. In the event of an error forward the JSON details of it as well, since the frontend must handle such cases.
Pair those 2 routes with this frontend approval flow: https://developer.paypal.com/demo/checkout/#/pattern/server . (If you need to send any additional data from the client to the server, such as an items array or selected options, add a body parameter to the fetch with a value that is a JSON string or object)

API for completing PayPal one-time payments

I'm looking for ways to make a PayPal payment using PHP. I understand there are deprecated APIs and current one. so I've found several ways to do so. but lots documents lead me into labyrinth. I'm quite confuse de.g. client button rendering, how to call our PHP script/ what is a PayPal-Request-Id and to get it/ what can we do with a token from webscr ==> cmd=_express-checkout&token=EC-7BA65327KY8480517 and etc.
I tried to use a button on my page to submit some few paypal-required parameters using html form. The receiving php file formed payment record as need, then create order. I got the order-id, but what is it for? so I set up a new parameters, conformed the PayPal needs to create a payment. This give me 4 links, one I choose to get redirected for client logging in and continuing. with this one I got to landing page then I executed a payment but each payment on sandbox dashboard says pending.
I am then confused how to get completed payment. Right here there is my data with THB currency
{"id":"PAYID-MAKU2OI7RR56034B9692111L","intent":"sale","state":"created","payer":{"payment_method":"paypal"},"transactions":[{"amount":{"total":"1126.15","currency":"THB","details":{"subtotal":"979.26","tax":"146.89","shipping":"0.00","insurance":"0.00","handling_fee":"0.00","shipping_discount":"0.00"}},"description":"aonang to","custom":"0","invoice_number":"kbv.starlight_12","soft_descriptor":"MFWD","payment_options":{"allowed_payment_method":"INSTANT_FUNDING_SOURCE","recurring_flag":false,"skip_fmf":false},"item_list":{"items":[{"name":"MFWD","sku":"kbv.starlight_12","description":"aonang to ","price":"979.26","currency":"THB","tax":"146.89","quantity":1}]},"related_resources":[]}],"note_to_payer":"Contact us for any questions on your order.","create_time":"2021-01-30T12:12:40Z","links":[{"href":"https://api.sandbox.paypal.com/v1/payments/payment/PAYID-MAKU2OI7RR56034B9692111L","rel":"self","method":"GET"},{"href":"https://www.sandbox.paypal.com/cgi-bin/webscr?cmd=_express-checkout&token=EC-1G552540DR9655320","rel":"approval_url","method":"REDIRECT"},{"href":"https://api.sandbox.paypal.com/v1/payments/payment/PAYID-MAKU2OI7RR56034B9692111L/execute","rel":"execute","method":"POST"}]}
Sandbox account interface screenshot
You mention the classic Express Checkout API and the deprecated v1/payments API, but the right solution is to use the current API, v2/checkout/orders
Create two routes on your server, one for 'Create Order' and one for 'Capture Order', documented here. These routes should return JSON data (and only JSON data) when called by an XHR/fetch.
Pair your two routes with the following approval flow: https://developer.paypal.com/demo/checkout/#/pattern/server

Paypal payment response without IPN listener?

I'm adding very simple membership renewal functionality to a web site using PayPal Payments Standard buttons. We only have 300 or so members, so a simple e-comm solution like this should work fine.
I'd like to capture some sort of confirmation that I can then capture on my end so that I can insert it into the database. I've seen the IPN listener method, but it seems more complex than I really need - all I really need is to pass the confirmation code via a URL variable in the return URL, i.e. http://www.example.com/landing?transactionid=abc123. Is this possible? Also, is there a way to pass my own dynamic variable (for instance, a membership ID) into the form and have that be a part of the return string?
Thanks
An alternative is to use express checkout which is a two step process requiring pre-authorization and then charging a customer. If you are accepting echecks you will eventually need to use IPN to update the original transaction. You can pass a dynamic variable using the custom field in Paypal.
Either way one of the two methods is required to process a transaction securely - what is stopping someone from typing the URL you are suggesting?

PayPal payment to issue activation code

I have just created my first PayPal button and it is working correctly within sand box. I would like to know the best way (if possible) to issue a unique activation code on my return url ensuring that the user has definitely paid before they receive the code. I could manually email the code but wondered if the was any way of automating this using some sort of return value? Possibly returning to an aspx page which then reads from my database to get the next activation key and displays it?
Thanks
Garry
As you already know that PayPal doesn't provide such facility for delivering activation instantly but it does offer the Instant Payment Notification API (PayPal IPN) which can be used to build such a platform.
Here is a great article for that purpose only. https://www.codeproject.com/Articles/383207/Selling-software-using-PayPal-IPN-as-an-eCommerceenter link description here
The best way to handle that would be to use Instant Payment Notification (IPN).
Any time a transaction happens on your site (whether it's a payment, refund, cleared pending payment, dispute, etc.) the PayPal server will POST details about that transaction to a script you have sitting on your server.
This script can receive the data and process it accordingly allowing you to automate things like updating a database, generating email notifications, hitting 3rd party web services, delivering e-goods, etc.
If you want the activation code to be visible on the return URL you can look at Payment Data Transfer (PDT), which is just like IPN except that it's made for use with the return URL. It is not recommended to use this, though, for post-transaction processing because there is no guarantee the user will make it back to the return URL, for one, and also it wouldn't handle things like e-checks correctly.

Payment subscription - test callback

We're currently looking at implementing Facebooks new subscription payments. We already have a working payment setup for Facebook, and the callback url is set correctly. If I make regular test payment the callback is called correctly.
The setup for testing subscriptions is according to this. But either if I choose the always success or always fail there is no callback made to the payments callback url.
It does return an object that says the subscription is active an has an ID.
{status: "active", subscription_id: 204626XXXXXX}
Is it possible you only get a request sent to the callback URL if the subscription state changes, and you already have an active subscription for the user? I would think you would get a client-side error in this case, but I don't see any evidence that there's an error code for that.
What happens if you make a regular test payment multiple times for the same account?
Facebook subscriptions are not regular purchase.
You will have to setup Real time updates on 'payment_subscriptions' object and listening to those available fields: ('status', 'pending_cancel', 'payment_status', 'last_payment'). See the documentation : http://developers.facebook.com/docs/payments/subscriptions/, there is a section called "Consuming Real time updates"
Each time an user subscribes or cancel (or an implicit renew), you will be hit with the related subscription id. You can then ask the Graph API about this subscription object.
You can also retrieve the list of subscriptions for any user via the Graph Api call on '/payment.subscriptions'
All these calls have to be performed with an App access token.
I must confess this process is quite annoying if you always performed "synchronous" purchases. I did implement subscriptions, this was a loooooong & painful travel ;)
Hope this helps
Subscriptions are mapped to OpenGraph objects on Facebook side, as well as virtual currency, so, I suspect there is no callback made to server side, all that you can do is make some kind of http post (through a form, for example) insde the FB.ui callback and implement the doPost method in a Servlet. That's would be a way to get subscription information into some data source.
Edit: concerning to payments callback, those items which order information are calculated based on OG object, facebook doesn't send a payments_get_items request, so there is no way to get order information after subscription creation. On the other hand, it could be possible that you receive some payments_status_update in the correspondent servlet (I'm talking about servlets because I'm a Java programmer, but the general idea applies for whichever technology you choose)