Showing posts with label paypal. Show all posts
Showing posts with label paypal. Show all posts

Saturday 9 November 2019

Paypal Mass Payment - Pay with email Address

Paypal Mass Payment - Pay with email Address

Mass Pay. Merchants can use the Mass Pay API to send money instantly to multiple recipients at once.


Question: Can I pay someone with their email address (Manual Transaction)?
Yes, you can pay.


Question: When money will deduct from sender account(Manual Transaction)?
As soon as you pay, money will be deducted from the sender account.


Question: When money will be credited to the receiver account(Manual Transaction)?
When you pay with email address and that email is already register with paypal.
Money will be credited immediately.

If email address is not registered, then receiver will get an email from paypal and he need to follow the steps in email to received.


Question: When money will deduct from sender account(Manual Transaction)?
As soon as you pay, money will be deducted from the sender account.


Question: What are transaction charges (Manual Transaction)?
If you are paying to your friend/family member and they are within same country - Its Free.
If you are paying for commerical purpose, No transaction charges for Sender/Buyer and (2.3% +.30 USD) will be deducted from seller/reciever.


Question: Can I can Cancel the payment after sending?
You can cancel only if he has not accept the payment.
but receiver can refund money to you.


Question: Is there any API available to pay with email address?

You can use MassPay API OR Adaptive Payments API. Question: What is Mass Paypal?
In this case, One Merchant can send the money to his partner's paypal email address (Paypal email address), mean each merchant must have paypal account. https://developer.paypal.com/docs/classic/mass-pay/integration-guide/MassPayOverview/


Question: What are keys of Mass Paypal through API?
  1. When we send payment with email address PayPal takes the payment amounts from your account and attempts to put them into the recipients' PayPal account.
  2. If the recipients do not have PayPal accounts, PayPal notifies them that a payment is available and they must create a PayPal account to receive the payment.
  3. Payments processing can take from a couple of minutes to several hours.
  4. PayPal will temporarily hold the total monetary value of the mass payment, plus associated fees, until processing is completed.
  5. If a payment is sent to a recipient who does not have a PayPal account, and it remains unclaimed for 30 days from the payment date, the money is returned to your PayPal account.
  6. Mass Payments need to enable for PayPal.
  7. You can only cancel payments that have an unclaimed payment.



Question: What is Mass Paypal Request parameter?
Array
(
    [METHOD] => MassPay
    [USER] => testname_api1.no-spam.ws
    [PWD] => 55555526677
    [SIGNATURE] => Alsdfdsfafdsfs.zYsROoDYkL2AigOq
    [VERSION] => 95
    [RECEIVERTYPE] => EmailAddress
    [CURRENCYCODE] => USD
    [L_EMAIL0] => testnamel@no-spam.ws
    [L_AMT0] => 10.00
    [L_EMAIL1] => testname2@no-spam.ws
    [L_AMT1] => 10.00
)



Thursday 7 April 2016

Paypal IPN Validation in PHP

Paypal IPN Validation in PHP

Question: How to IPN? How to set IPN in Paypal?
http://www.web-technology-experts-notes.in/2016/03/instant-payment-notification-paypal.html


Question: Why we need to validate the IPN?
To make sure, all data sent in our server is from Paypal.


Question: What are benefits of validating the IPN?
  1. Protect our transaction from SPAM OR robots OR from hackers.
  2. Protect from dmmmy entires in our database.
  3. If protection is ON, We will always sure for transaction record in database.



Question: What does paypal do with valiation?
It will validate all the data, sent to paypal.


Question: What is name of parameter which is send to paypal for validation?
cmd.
For Example:
cmd=_notify-validate



Question: What does paypal return if validation failed?
INVALID


Question: How does paypal return, if validation passed?
VERIFIED


Question: How to validate IPN Response in Sandbox Mode?
$ipnData=$_POST;
$ipnData['cmd']='_notify-validate';
$verify= file_get_contents('https://www.sandbox.paypal.com/cgi-bin/webscr', false, stream_context_create(array(
            'http' => array(
                'header'  => "Content-type: application/x-www-form-urlencoded\r\nUser-Agent: MyAPP 1.0\r\n",
                'method'  => 'POST',
                'content' => http_build_query($ipnData)
            )
        )));  
if($verify=='VERIFIED'){
/** Your data is valid and it is return from paypal */

}



Question: How to validate Paypal IPN Response in LIVE Mode ?
$ipnData=$_POST;
$ipnData['cmd']='_notify-validate';
$verify= file_get_contents('https://www.paypal.com/cgi-bin/webscr', false, stream_context_create(array(
            'http' => array(
                'header'  => "Content-type: application/x-www-form-urlencoded\r\nUser-Agent: MyAPP 1.0\r\n",
                'method'  => 'POST',
                'content' => http_build_query($ipnData)
            )
        )));  
if($verify=='VERIFIED'){
/** Your data is valid and it is return from paypal */

}


Question: How to validate IPN Validate with curl?
$ipnData=$_POST;
$ipnData['cmd']='_notify-validate';

$validateURL='https://www.paypal.com/cgi-bin/webscr';//for paypal
//$validateURL='https://www.sandbox.paypal.com/cgi-bin/webscr'; //for sandbox paypal
   
$ch = curl_init($validateURL);
curl_setopt($ch, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($ipnData));
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
curl_setopt($ch, CURLOPT_FORBID_REUSE, 1);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Connection: Close'));
if ( !($verify = curl_exec($ch)) ) {          
 curl_close($ch);
 die('Some Error');
}
curl_close($ch); 
var_dump($verify );//IF VERIFIED, then validate




Thursday 31 March 2016

Instant Payment Notification paypal

Instant Payment Notification paypal

Question: What is IPN?
IPN is a message service by paypal that notifies you regarding PayPal transactions.


Question: What is full form of IPN?
Full form of IPN is Instant Payment Notification.


Question: For what type of transactions, paypal send notification?
  1. Instant payments (including Express Checkout payments, direct credit card payments, and calls made to the Adaptive Payments API)
  2. eCheck payments (status pending, completed, and denied)
  3. Pending payments
  4. Authorizations
  5. Recurring payments and subscription payment actions
  6. Chargebacks, disputes, reversals, and refunds associated with different transactions



Question: From where I can send IPN online?
https://developer.paypal.com/developer/ipnSimulator/
(for this, First you MUST set IPN URL in your account)


Question: Give me URL of IPN Simulator?
https://developer.paypal.com/developer/ipnSimulator/
(for this, First you MUST set IPN URL in your account and that must be https URL)


Question: Can I test IPN Simulator in local system?
No, You can't.


Question: Where I can set IPN URL?
Login to Merchant Account => Merchant Services => Instant payment notifications (click on link)
Direct Link for Sandbox: https://www.sandbox.paypal.com/cgi-bin/customerprofileweb?cmd=_profile-ipn-notify
Direct Link for Paypal: https://www.paypal.com/cgi-bin/customerprofileweb?cmd=_profile-ipn-notify


Question: In PayNow Form, Can i set IPN URL? If yes, how?
Yes, you can set.
<input name="notify_url" type="hidden" value="http://example.com/ipn-url.php" />       



Question: What is Full form of PDT?
Full form of PDT is PayPal Payment Data Transfers.


Question: What is PDT? and What is use of PDT?
PDT is for notification similar to IPN.


Question: How PDT is different from IPN?
With PDT you get the notification instantly and can do any additional processing required and show the user a confirmation page.
Whereas IPN you are guaranteed to be notified that the payment was received even computer get crash after payments.


Question: From where i can view the IPN History?
https://www.paypal.com/us/cgi-bin/webscr?cmd=_display-ipns-history


Tuesday 29 March 2016

Paypal Buynow button with Dynamic Fields

paypal buynow button with dynamic fields


DEMO - (Please Don't do Payment).





Sandbox Custom Button
<form action="https://www.sandbox.paypal.com/cgi-bin/webscr" method="post">
<input name="cmd" type="hidden" value="_xclick" />
    <input name="business" type="hidden" value="business_a@no-spam.ws" />
    <input name="no_shipping" type="hidden" value="1" />    
    <input name="item_name" type="hidden" value="Product Name" />
    <input name="item_number" type="hidden" value="123456" />
    <input name="amount" type="hidden" value="10.25" />
    <input name="currency_code" type="hidden" value="USD" />
    <input alt="PayPal - The safer, easier way to pay online!" border="0" name="submit" src="https://www.sandbox.paypal.com/en_US/i/btn/btn_buynowCC_LG.gif" type="image" />
    <input name="return" type="hidden" value="http://example.com/ohio-university/success/tour_type/private" />
    <input name="cancel_return" type="hidden" value="http://example.com/ohio-university/cancelled/order_id/00010" />        
    <input name="notify_url" type="hidden" value="http://example.com/ohio-university/ipn/order_id/00010" />        
    <input name="button_subtype" type="hidden" value="services" />
</form>




Paypal Custom Button
<form action="https://www.paypal.com/cgi-bin/webscr" method="post">
<input name="cmd" type="hidden" value="_xclick" />
    <input name="business" type="hidden" value="business_a@no-spam.ws" />
    <input name="no_shipping" type="hidden" value="1" />
    <input name="item_name" type="hidden" value="Product Name" />
    <input name="item_number" type="hidden" value="123456" />
    <input name="amount" type="hidden" value="10.25" />
    <input name="currency_code" type="hidden" value="USD" />
    <input alt="PayPal - The safer, easier way to pay online!" border="0" name="submit" src="https://www.paypal.com/en_US/i/btn/btn_buynowCC_LG.gif" type="image" />
    <input name="return" type="hidden" value="http://example.com/ohio-university/success/tour_type/private" />
    <input name="cancel_return" type="hidden" value="http://example.com/ohio-university/cancelled/order_id/00010" />        
    <input name="notify_url" type="hidden" value="http://example.com/ohio-university/ipn/order_id/00010" />        
    <input name="button_subtype" type="hidden" value="services" />
</form>

Understand the Hidden variables
  1. cmd:value is _xclick, means this is Buy Now page.
  2. business: paypal email address where you will received the payment.
  3. no_shipping: Show the shipping details in paypal checckout page, 0-Hide, 1-Show.
  4. item_name: Product Name display in paypal cart page.
  5. item_number: this is order number and should be always unique.
  6. amount: Amount of order.
  7. currency_code: Currency code of order amount.
  8. return: After order complete, user will return to this URL.
  9. cancel_return: If user cancel the payment in paypal checkout page, he will return to this URL.
  10. notify_url: This is notify URL for developer, where developer update the details after payment success/failed/onHold etc.


Saturday 28 November 2015

PayPal Express Checkout Working Flow - In Simple Steps with Clean Example


PayPal Express Checkout Working Flow
PayPal Express Checkout is a powerful API-based solution that can be integrated into any merchant website. With PayPal Express Checkout API, customer leave the website and complete the transaction in http://paypal.com, where customer can pay with paypal.com account OR with credit card / Debit card. When start processing, Paypal gives a TOKEN key which is used to charge money from customer OR get the Payment Details OR Customer Shipping/Billing details. Developer should save this token key for future use.


Express Checkout have Simple Seven Steps. Start from initializing the token and end with success page after payment.


Customer makes their payment and completes their order on your website. This enables tighter integration with your website and order management processes. It can be more efficient for PayPal users and may facilitate sales.



Following are 7 Steps of express Checkout
Step 1: Get Token API In this case we need to send an API call to Paypal Server with item detail, receiver email etc.
Request Parameter Example
Array
(
    [USER] => PAYPAL_API_EMAIL
    [PWD] => PAYPAL_API_PASSWORD
    [SIGNATURE] => PAYPAL_API_SIGNATURE
    [VERSION] => 95
    [ip] => 127.0.0.1
    [METHOD] => SetExpressCheckout
    [returnUrl] => http://example.com/order/success //customer will return this URL, if paid
    [cancelUrl] => http://example.com/order/failed //customer will return this URL, if not paid
    [L_PAYMENTREQUEST_0_NAME0] => Om Belt - Black
    [L_PAYMENTREQUEST_0_DESC0] => Obscure Belts
    [L_PAYMENTREQUEST_0_AMT0] => 82.92
    [L_PAYMENTREQUEST_0_QTY0] => 1
    [PAYMENTREQUEST_0_CURRENCYCODE] => USD
    [PAYMENTREQUEST_0_SHIPPINGAMT] => 5.15
    [PAYMENTREQUEST_0_AMT] => 88.07
    [PAYMENTREQUEST_0_ITEMAMT] => 82.92
    [PAYMENTREQUEST_0_PAYMENTACTION] => Order
    [PAYMENTREQUEST_0_SELLERPAYPALACCOUNTID] => receiver_email_address;//payment will receive by this paypal email
    [PAYMENTREQUEST_0_PAYMENTREQUESTID] => ORDER_UNIQUE_ID
)

Step 2: Get Token From API Response After calling above API, we will get below response
Array
(
    [TOKEN] => EC-06N33746DC1035058
    [TIMESTAMP] => 2014-08-11T11:40:52Z
    [CORRELATIONID] => dcda5dabca4a7
    [ACK] => Success
    [VERSION] => 95
    [BUILD] => 12301660
)
Now, Store the TOKEN will be used in future


Step 3: Send Customer to Paypal After getting success, we will send customer to following URL with appending token key
https://www.sandbox.paypal.com/cgi-bin/webscr?cmd=_express-checkout&useraction=commit&token=EC-06N33746DC1035058
Here User will see Cart detail and can pay after login.

Step 4: Order Confirmation Page After login successfully, Customer will move to Order Confirmation page with "Pay Now" Button
(Here user will see the cart detail and can pay)

Step 5: Get Order Detail When Customer paid successfully, customer will return to returnUrl (see step1), In return URL, TOKEN and PayerID will be appended automatically.
From TOKEN, we will get to know for what order user return.
From PayerID, We will get to know user is ready to pay us and also we used this Id to charge him.

Call following API, to get the Order Detail From Paypal
Array
(
    [USER] => PAYPAL_API_EMAIL
    [PWD] => PAYPAL_API_PASSWORD
    [SIGNATURE] => PAYPAL_API_SIGNATURE
    [VERSION] => 95
    [url] => https://api-3t.sandbox.paypal.com/nvp
    [METHOD] => GetExpressCheckoutDetails
    [TOKEN] => EC-06N33746DC1035058
)

After calling above API, response will be return

Step 6: Charge Money From Customer We need to a new paypal method to charge the customer i.e DoExpressCheckoutPayment
Request Params Example
Array
(
    [USER] => PAYPAL_API_EMAIL
    [PWD] => PAYPAL_API_PASSWORD
    [SIGNATURE] => PAYPAL_API_SIGNATURE
    [VERSION] => 95
    [url] => https://api-3t.sandbox.paypal.com/nvp
    [METHOD] => DoExpressCheckoutPayment
    [TOKEN] => EC-06N33746DC1035058
    [PAYERID] => HS5JSKPGX4T2G
    [L_PAYMENTREQUEST_0_NAME0] => Om Belt - Black
    [L_PAYMENTREQUEST_0_DESC0] => Obscure Belts
    [L_PAYMENTREQUEST_0_AMT0] => 82.92
    [L_PAYMENTREQUEST_0_QTY0] => 1
    [PAYMENTREQUEST_0_CURRENCYCODE] => USD
    [PAYMENTREQUEST_0_SHIPPINGAMT] => 5.15
    [PAYMENTREQUEST_0_AMT] => 88.07
    [PAYMENTREQUEST_0_ITEMAMT] => 82.92
    [PAYMENTREQUEST_0_SELLERPAYPALACCOUNTID] => receiver_email_address//payment will receive by this paypal email
   
)

When we call DoExpressCheckoutPayment, We will charge the payment from customer Account and an email will be sent to customer and receiver.

Step 7: Check Resonse
Array
(
    [TOKEN] => EC-06N33746DC1035058
    [SUCCESSPAGEREDIRECTREQUESTED] => false
    [TIMESTAMP] => 2014-08-11T12:41:32Z
    [CORRELATIONID] => e5d0b3a5e674a
    [ACK] => Success
    [VERSION] => 95
    [BUILD] => 12301660
    [INSURANCEOPTIONSELECTED] => false
    [SHIPPINGOPTIONISDEFAULT] => false
    [PAYMENTINFO_0_TRANSACTIONID] => 6HD429843V086060C
    [PAYMENTINFO_0_TRANSACTIONTYPE] => cart
    [PAYMENTINFO_0_PAYMENTTYPE] => instant
    [PAYMENTINFO_0_ORDERTIME] => 2014-08-11T12:41:32Z
    [PAYMENTINFO_0_AMT] => 88.07
    [PAYMENTINFO_0_FEEAMT] => 2.85
    [PAYMENTINFO_0_TAXAMT] => 0.00
    [PAYMENTINFO_0_CURRENCYCODE] => USD
    [PAYMENTINFO_0_PAYMENTSTATUS] => Completed
    [PAYMENTINFO_0_PENDINGREASON] => None
    [PAYMENTINFO_0_REASONCODE] => None
    [PAYMENTINFO_0_PROTECTIONELIGIBILITY] => Eligible
    [PAYMENTINFO_0_PROTECTIONELIGIBILITYTYPE] => ItemNotReceivedEligible,UnauthorizedPaymentEligible
    [PAYMENTINFO_0_SELLERPAYPALACCOUNTID] => receiver_email_address
    [PAYMENTINFO_0_SECUREMERCHANTACCOUNTID] => UFBX24KTUHJKU
    [PAYMENTINFO_0_ERRORCODE] => 0
    [PAYMENTINFO_0_ACK] => Success
)


Customer can pay with Credit card without Paypal Account

  1. Login to Paypal
  2. Go to Profile subtab
  3. Click on Website Payment Preferences under the Selling Preferences column
  4. Check the yes box under PayPal Account Optional