cancel
Showing results forย 
Search instead forย 
Did you mean:ย 

paypal integration and testing

I use sandbox for simple pay, my form is:

<form method="post" action="https://www.sandbox.paypal.com/cgi-bin/webscr" name="paypal">
    <input type="hidden" value="_cart" name="cmd">
    <input type="hidden" value="1" name="upload">
    <input type="hidden" value="1" name="no_note">
    <input type="hidden" value="1" name="no_shipping">
    <input type="hidden" value="USD" name="currency_code">
    <input type="hidden" value="{{my external script here[http://example.com]}}" name="notify_url">
    <input type="hidden" value="{{my email}}" name="business">
    <input type="hidden" value="Eko " name="item_name_1">
    <input type="hidden" value="107-372" name="item_number_1">
    <input type="hidden" value="0.50" name="amount_1">
    <input type="hidden" value="1" name="quantity_1">
    <input type="hidden" value="E-mail" name="item_name_2">
    <input type="hidden" value="Free Shipping" name="item_number_2">
    <input type="hidden" value="0.00" name="amount_2">
    <input type="hidden" value="1" name="quantity_2">
    <input type="hidden" value="0.23" name="tax_cart">
    <input type="hidden" value="0" name="discount_amount_cart">
    <input type="hidden" value="http://test.t/put-log.php" name="return">
    <input type="hidden" value="http://test.t/raw.html" name="cancel_return">
    <input type="submit">
</form>

After submit this form I pay using another sandbox account. My payment is correct but Im not redirecting to notify_url, looks like my IPN is lost or not sending, maybe because sandbox mode or any other idea?

DeepMohinman
Member
3 REPLIES 3

Create PayPal payment
After you collect the payment details from the customer, specify the payment details in a /payment call.

In the request URI, set the <Access-Token>.

In the JSON request body, set the intent to sale, the redirect URLs, the payment_method to paypal, and the transaction information in the transactions array, which contains one or more transaction objects:

curl -v -X POST https://api-m.sandbox.paypal.com/v1/payments/payment \
-H "Content-Type: application/json" \
-H "Authorization: Bearer <Access-Token>" \
-d '{
"intent": "sale",
"payer": {
"payment_method": "paypal"
},
"transactions": [{
"amount": {
"total": "30.11",
"currency": "USD",
"details": {
"subtotal": "30.00",
"tax": "0.07",
"shipping": "0.03",
"handling_fee": "1.00",
"shipping_discount": "-1.00",
"insurance": "0.01"
}
},
"description": "This is the payment transaction description.",
"custom": "EBAY_EMS_90048630024435",
"invoice_number": "48787589673",
"payment_options": {
"allowed_payment_method": "INSTANT_FUNDING_SOURCE"
},
"soft_descriptor": "ECHI5786786",
"item_list": {
"items": [{
"name": "hat",
"description": "Brown color hat",
"quantity": "5",
"price": "3",
"tax": "0.01",
"sku": "1",
"currency": "USD"
}, {
"name": "handbag",
"description": "Black color hand bag",
"quantity": "1",
"price": "15",
"tax": "0.02",
"sku": "product34",
"currency": "USD"
}],
"shipping_address": {
"recipient_name": "Hello World",
"line1": "4thFloor",
"line2": "unit#34",
"city": "SAn Jose",
"country_code": "US",
"postal_code": "95131",
"phone": "011862212345678",
"state": "CA"
}
}
}],
"note_to_payer": "Contact us for any questions on your order.",
"redirect_urls": {
"return_url": "https://example.com",
"cancel_url": "https://example.com"
}
}'
A successful call returns confirmation of the transaction, with the created state and a payment ID that you can use in subsequent calls:

{
"id": "PAY-1B56960729604235TKQQIYVY",
"create_time": "2014-09-22T20:53:43Z",
"update_time": "2014-09-22T20:53:44Z",
"state": "created",
"intent": "sale",
"payer": {
"payment_method": "paypal"
},
"transactions": [
{
"amount": {
"total": "30.11",
"currency": "USD",
"details": {
"subtotal": "30.00",
"tax": "0.07",
"shipping": "0.03",
"handling_fee": "1.00",
"insurance": "0.01",
"shipping_discount": "-1.00"
}
},
"description": "This is the payment transaction description.",
"custom": "EBAY_EMS_90048630024435",
"invoice_number": "48787589673",
"item_list": {
"items": [
{
"name": "hat",
"sku": "1",
"price": "3.00",
"currency": "USD",
"quantity": "5",
"description": "Brown color hat",
"tax": "0.01"
},
{
"name": "handbag",
"sku": "product34",
"price": "15.00",
"currency": "USD",
"quantity": "1",
"description": "Black color handbag",
"tax": "0.02"
}
],
"shipping_address": {
"recipient_name": "HelloWorld",
"line1": "4thFloor",
"line2": "unit#34",
"city": "SAn Jose",
"state": "CA",
"phone": "011862212345678",
"postal_code": "95131",
"country_code": "US"
}
}
}
],
"links": [
{
"href": "https://api-m.paypal.com/v1/payments/payment/PAY-1B56960729604235TKQQIYVY",
"rel": "self",
"method": "GET"
},
{
"href": "https://api-m.paypal.com/v1/payments//cgi-bin/webscr?cmd=_express-checkout&token=EC-60385559L1062554...",
"rel": "approval_url",
"method": "REDIRECT"
},
{
"href": "https://api-m.paypal.com/v1/payments/payment/PAY-1B56960729604235TKQQIYVY/execute",
"rel": "execute",
"method": "POST"
}
]
}
Next, get approval from the customer for the payment.

Get payment approval
When you create a payment for a PayPal payment, the customer must approve the payment before you can execute the sale. To enable the customer to approve the payment, pass the id field to the payment function on your client. When the customer approves the payment, PayPal calls your client-side onAuthorize callback. PayPal passes the data.paymentID and data.payerID to your call back.

Note: For existing full-page-redirect integrations, redirect the customer to the approval_url from the create-payment response so that he or she can approve the payment.

For NVP/SOAP API full-page redirect integrations, PayPal does a full-page redirect to the return_url that was specified when the payment was created, with PayerID and paymentId appended to the URL. 

Obrien45050
Member

I might misunderstand something but last time i was integrating PayPal on my Rails application it wasn't that hard - make a unique custom data id for every transaction, save it in db, let user pay via link, wait for the response from IPN, resend a confirmation you got that info to paypal and make sure transaction really occured, check if mc_gross/mc_gross1 is correct and that the status is 'complete' (if not - save it in some kind of a log so i can check it up later)... something critical I missed? Cuz from what ive seen payments go through and are registered correctly.

You can sign up for a developer account at https://developer.paypal.com/ voojio- this allows you to set up multiple buyer/seller accounts. Keep in mind that Sandbox is fully separated from the live environment; so any emails will be directed to the 'Test emails' section on https://developer.paypal.com/ omegleshagle rather than being sent out externally. Should you need to get specific access to an API call (i.e., Reference Transactions), just log a thread at x.com or paypal.com/mts

DeepMohinman
Member