Вопрос

I'm trying to implement the flow "Setting Up Web Pages to Invoke the Embedded Payment Flow Using a Lightbox" described here https://developer.paypal.com/webapps/developer/docs/classic/adaptive-payments/integration-guide/APIntro/

I'm able to get the initial paykey and I get as response something like this:

{u'responseEnvelope': {u'ack': u'Success', u'timestamp': u'2013-08-06T01:59:32.228-07:00', u'build': u'6941298', u'correlationId': u'3f9b3609b9069'}, u'paymentExecStatus': u'CREATED', u'payKey': u'AP-4C138527MX750433P'}

At this point we are able to display a "Pay with PayPal" button on our website, follow the payment etc.... the problem is now with IPN notification.

I've tried the IPN simulator and what it sends is a POST with these values (for example):

Key: last_name - Value: Smith
Key: txn_id - Value: 245929950
Key: receiver_email - Value: seller@paypalsandbox.com
Key: payment_status - Value: Completed
Key: tax - Value: 2.02
Key: residence_country - Value: US
Key: invoice - Value: abc1234
Key: address_state - Value: CA
Key: payer_status - Value: verified
Key: txn_type - Value: web_accept
Key: address_country - Value: United States
Key: payment_date - Value: 01:43:47 6 Aug 2013 PDT
Key: first_name - Value: John
Key: item_name - Value: something
Key: address_street - Value: 123, any street
Key: mc_gross1 - Value: 12.34
Key: custom - Value: xyz123
Key: notify_version - Value: 2.1
Key: address_name - Value: John Smith
Key: test_ipn - Value: 1
Key: item_number - Value: AK-1234
Key: receiver_id - Value: seller@paypalsandbox.com
Key: business - Value: seller@paypalsandbox.com
Key: payer_id - Value: TESTBUYERID01
Key: verify_sign - Value: AFcWxV21C7fd0v3bYYYRCpSSRl31A.8pFOgHmGMTg8Lj.JUvXyp3bu63
Key: address_zip - Value: 95131
Key: address_country_code - Value: US
Key: address_city - Value: San Jose
Key: address_status - Value: confirmed
Key: mc_fee - Value: 0.44
Key: mc_currency - Value: USD
Key: shipping - Value: 3.04
Key: payer_email - Value: buyer@paypalsandbox.com
Key: payment_type - Value: echeck
Key: mc_gross - Value: 12.34
Key: quantity - Value: 1

The fact is that our server that accept IPN posts must be able to accept any number of transactions. So, when I receive a message like this, how do I know which paykey is related to?

1) I could track the payment with payer_email, but what if the payer wants to login and pay with a different PayPal account?

2) What happens if there are two pending payments from the same PayPal account?

3) What if the payer doesn't want to create a PayPal account and want to pay with his credit card?

In these three situations I would not be able to connect the IPN message received to my initial transaction (that I identify with the paykey).

It looks like I'm missing something.... can anyone please help me? Thanks!

Это было полезно?

Решение

If you want to pass a custom variable to Paypal when the user goes there from your site, that gets returned to your IPN when the transaction is complete, you want to use the custom field in the button.

<form name="_xclick" action="https://www.paypal.com/ca/cgi-bin/webscr" method="post">
<input type="hidden" name="cmd" value="_xclick">
<input type="hidden" name="custom" value="paykey:aBjKmNi223">
<input type="image" src="http://www.paypal.com/en_US/i/btn/x-click-but01.gif" border="0"     name="submit" alt="Make payments with PayPal - it's fast, free and secure!">
</form>

And your IPN response will look like this...

Key: last_name - Value: Smith
Key: txn_id - Value: 245929950
Key: receiver_email - Value: seller@paypalsandbox.com
Key: custom - Value: paykey:aBjKmNi223

Note this only works for the field called custom. You cannot use just any field. If you want to pass multiple objects, use a comma-delineated string in the custom field.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top