PayPal Using Payflow to create Recurring Payment with PayPal account - paypal

My clients don't want to handle credit card data so I have implemented 2 options, 1) PayPal Advanced with Hosted Pages, and 2) PayPal Pro Transparent redirect. I am able to create recurring payments by
Getting my secure token
Committing a transaction
Converting transaction to Recurring Billing Profile
PayPal requires that I give the user the option to pay with a PayPal account but when I convert that payment to a RBP and then let it create a transaction the trans fails with result 7 - Field Format Error. I notice that the RBP created has no account number.
With option 1 I think I'm out of luck yes?
With option 2, I use Payflow.net dll to process the EC which works fine (see code sample). Is there a code sample somewhere on how to create a RBP with a token instead of a CC num or BAID?
...
partner = pageSettings.PageSettings["PayPalPartner"];
vendor = pageSettings.PageSettings["PayPalLogin"];
user = pageSettings.PageSettings["PayPalUser"];
pwd = Utilities.DecryptSettingValue(pageSettings.PageSettings["PayPalPassword"])
UserInfo creds = new UserInfo(user, vendor, partner, pwd);
string url = ConfigurationManager.AppSettings.Get("PayflowLive");
PayflowConnectionData connection = new PayflowConnectionData(url);
ECDoRequest doRequest = new ECDoRequest(token, payerID);
PayPalTender tender = new PayPalTender(doRequest);
Invoice inv = new Invoice();
inv.Amt = new Currency(amount, "USD");
inv.Comment1 = fundName;
SaleTransaction trans = new SaleTransaction(creds, connection, inv, tender, PayflowUtility.RequestId);
Response resp = trans.SubmitTransaction();

I don't have the code but I can direct you on how you can create the recurring profile using the PayPal Payments . It includes the four steps :
1. Call the SetExpressCheckout API
VENDOR=XXXXXXX&PARTNER=XXXXXXX&USER=XXXXXXXXX&PWD=XXXXXX&TRXTYPE=A&ACTION=S&TENDER=P&RETURNURL=http://return.com&CANCELURL=http://cancel.com&AMT=0.00&BA_DESC=purchase Time magazine&BILLINGTYPE=MerchantInitiatedBilling&PAYMENTTYPE=any&BA_CUSTOM=magazine subscription
NVP Response:
RESULT=0
RESPMSG=Verified
TOKEN=EC-8DA60888D41196708
CORRELATIONID=f4df94a3345b6
2.Redirect the customer using the generated token :
https://www.sandbox.paypal.com/cgi-bin/webscr?cmd=_express-checkout&token=EC-8DA60888D41196708
3. Once the buyer accept the agreement use the token to get the billing agreement id
NVP Request:
VENDOR=XXXXXX&PARTNER=XXXXXXX&USER=XXXXXXXX&PWD=XXXXX&TRXTYPE=A&ACTION=X&TENDER=P&TOKEN=EC-8DA60888D41196708
NVP Response:
RESULT=0
PNREF=B1PP7A2F8154
RESPMSG=Approved
TOKEN=EC-8DA60888D41196708
CORRELATIONID=49d6b0037408
BAID=B-6A290557S1180001J
4. After getting BAID , make a call to create the recurring billing using BAID
NVP Request:
VENDOR=XXXX&PARTNER=XXXX&USER=XXXXXX&PWD=XXXXX&TRXTYPE=R&TENDER=P&ACTION=A&PROFILENAME=RegularSubscription&AMT=4.46&BAID=B-6A290557S1180001J&START=09212014&PAYPERIOD=WEEK&TERM=12&MAXFAILPAYMENTS=1&RETRYNUMDAYS=1&CURRENCY=USD
NVP Response:
RESULT=0
RPREF=R1P57A2F8538
PROFILEID=RT0000000010
RESPMSG=Approved

Related

Getting the Unique Transaction ID seen by the customer from Express Checkout

I'm using PayPal Express Checkout on a sandbox account, and i'm trying to link up the Unique Transaction ID on the "customer" paypal site with the completed transaction via Express Checkout.
My DoExpressCheckoutPayment returned:
TOKEN=EC%2d2KG36160AM8868619&
SUCCESSPAGEREDIRECTREQUESTED=false&
TIMESTAMP=2015%2d01%2d29T09%3a45%3a09Z&
CORRELATIONID=44060412ed341&
ACK=Success&
VERSION=93&BUILD=15009693&
INSURANCEOPTIONSELECTED=false&
SHIPPINGOPTIONISDEFAULT=false&
PAYMENTINFO_0_TRANSACTIONID=011446947E558235S&
PAYMENTINFO_0_TRANSACTIONTYPE=expresscheckout&
PAYMENTINFO_0_PAYMENTTYPE=instant&
PAYMENTINFO_0_ORDERTIME=2015%2d01%2d29T09%3a45%3a08Z&
PAYMENTINFO_0_AMT=7%2e98&
PAYMENTINFO_0_FEEAMT=0%2e47&
PAYMENTINFO_0_TAXAMT=0%2e00&
PAYMENTINFO_0_CURRENCYCODE=GBP&
PAYMENTINFO_0_PAYMENTSTATUS=Completed&
PAYMENTINFO_0_PENDINGREASON=None&
PAYMENTINFO_0_REASONCODE=None&
PAYMENTINFO_0_PROTECTIONELIGIBILITY=Ineligible&
PAYMENTINFO_0_PROTECTIONELIGIBILITYTYPE=None&
PAYMENTINFO_0_SECUREMERCHANTACCOUNTID=W9SM36U76AXSS&
PAYMENTINFO_0_ERRORCODE=0&
PAYMENTINFO_0_ACK=Success
Then my GetExpressCheckoutDetails returned:
TOKEN=EC%2d2KG36160AM8868619&
BILLINGAGREEMENTACCEPTEDSTATUS=0&
CHECKOUTSTATUS=PaymentActionCompleted&
TIMESTAMP=2015%2d01%2d29T09%3a45%3a33Z&
CORRELATIONID=80e00a0067bea&
ACK=Success&
VERSION=93&
BUILD=15009693&
EMAIL=test1%40sud%2eco2euk&
PAYERID=H54VEN293PLFL&
PAYERSTATUS=verified&
FIRSTNAME=Test&
LASTNAME=User&
COUNTRYCODE=GB&
CURRENCYCODE=GBP&
AMT=7%2e98&
SHIPPINGAMT=0%2e00&
HANDLINGAMT=0%2e00&
TAXAMT=0%2e00&
INSURANCEAMT=0%2e00&
SHIPDISCAMT=0%2e00&
PAYMENTREQUEST_0_CURRENCYCODE=GBP&
PAYMENTREQUEST_0_AMT=7%2e98&
PAYMENTREQUEST_0_SHIPPINGAMT=0%2e00&
PAYMENTREQUEST_0_HANDLINGAMT=0%2e00&
PAYMENTREQUEST_0_TAXAMT=0%2e00&
PAYMENTREQUEST_0_INSURANCEAMT=0%2e00&
PAYMENTREQUEST_0_SHIPDISCAMT=0%2e00&
PAYMENTREQUEST_0_TRANSACTIONID=011446947E558235S&
PAYMENTREQUEST_0_INSURANCEOPTIONOFFERED=false&
PAYMENTREQUESTINFO_0_TRANSACTIONID=011446947E558235S&
PAYMENTREQUESTINFO_0_ERRORCODE=0
But the customer site says:
PayPal Express Checkout Payment Sent (Unique Transaction ID 7PK53077PJ222701T)
Oh..the (painful) memories :) That aforementioned "oddity" also exists elsewhere - e.g. eBay transactions
IINM, you'll need to send your own "custom ID" - the Invoice Id mentioned above (which is displayed to the end user) so both ends have some visual reference to a transaction.
In the REST API (unsure in Classic, haven't tried), if you send an Order, the Order Number (finally) is shared on both ends (same for both). Though it wouldn't hurt to still send your own "custom Id"/"Invoice Id".
Buyer/Customer Paypal UI:
Seller/Merchant Paypal UI:
Hth...

Cannot capture amounts after DoExpressCheckoutPayment with parallel payment

I user PayPal's Express Checkout API to make an parallel Payment. Everything works fine, on the payee site, the 2 payments are booked as "open".
While DoExpressCheckoutPayment I get an transaction id for each payment. But a doCapture fails with "You%20do%20not%20have%20permissions%20to%20make%20this%20API%20call". A single authorized payment that I made several weeks ago but have never captured gives me just "Order%20has%20expired%2e" - which is fine.
I use the following parameters for the NVP API:
$parameters = array("METHOD"=>"DoCapture",
"AUTHORIZATIONID"=>$transactionid_item,
"AMT"=>$amt_item,
"CURRENCYCODE"=>$currencycode,
"COMPLETETYPE"=>"Complete"
);
when of course the variable are the corresponding values to each payment. (plus authentication/api credential).
What am I doing wrong? Is there an additional variable to set when I make a parallel instead of an single payment?
regards,
chris
This is an example call and the response:
https://api-3t.sandbox.paypal.com/nvp?METHOD=DoCapture&AUTHORIZATIONID=O-67121848EA448750G&AMT=9.70&CURRENCYCODE=EUR&COMPLETETYPE=Complete&USER=xxx&PWD=xxx&SIGNATURE=xxx&VERSION=95.0
array(9) {
["TIMESTAMP"]=>
string(28) "2013%2d06%2d15T09%3a35%3a52Z"
["CORRELATIONID"]=>
string(12) "140dec053198"
["ACK"]=>
string(7) "Failure"
["VERSION"]=>
string(6) "95%2e0"
["BUILD"]=>
string(7) "6444009"
["L_ERRORCODE0"]=>
string(5) "10007"
["L_SHORTMESSAGE0"]=>
string(19) "Permission%20denied"
["L_LONGMESSAGE0"]=>
string(67) "You%20do%20not%20have%20permissions%20to%20make%20this%20API%20call"
["L_SEVERITYCODE0"]=>
string(5) "Error"
}
It looks like you are running your Express Checkout API call as an order, then you are turning around and doing a DoCapture request but you are passing over the order id for the auth id instead of the authorization id. If you are wanting to set your Express Checkout to be an order instead of an auth or a sale, then you need to perform the calls in the following ways.
SetExpressCheckout API call (processing as order)
GetExpressCheckoutDetail API Call
DoExpressCheckoutPayment API Call (processing as order)
DoAuthorization (performs an auth, and passes over the order id that you received from the EC flow)
DoCapture (performs a capture against the auth, you will pass over the auth id that was returned in the previous call here, not the order id)

PayPal SOAP API (.NET) - refund transaction error 10004 The transaction id is not valid

I'm using PayPal SOAP SDK for .NET to make a refund transaction.I try to call RefundTransaction method in SDK using transaction ID from SetExpressCheckout/DoExpressCheckout calls ( they work well ). PayPal API is returning 10004 error "Transaction id is not valid".
Here is my code:
PayPalAPIInterfaceServiceService service = new PayPalAPIInterfaceServiceService();
RefundTransactionRequestType refundTransactionRequest = new RefundTransactionRequestType();
refundTransactionRequest.TransactionID = transactionID;
refundTransactionRequest.PayerID = payerID;
refundTransactionRequest.InvoiceID = invoiceNumber;
refundTransactionRequest.RefundType = RefundType.FULL;
refundTransactionRequest.Amount = new BasicAmountType(GetPayPalCurrency(currencyID), amount.ToString("F"));
var request = new RefundTransactionReq() { RefundTransactionRequest = refundTransactionRequest };
RefundTransactionResponseType refundTransactionResponse = service.RefundTransaction(request);
Please help.
Double check to make sure that you processed the DoExpressCheckout transaction as a sale and not an authorization. If it was an authorization, you will not be able to refund it. Also make sure you are using the transaction id that you received as the merchant, and not the transaction id you received as a buyer. The two transaction id's will be different. If you have checked both of these things and it still does not work, if you can provide the API response you are getting back that includes the TIMESTAMP and the CORRELATIONID I can take a look at it on my end.

paypal checkout display shipping costs but does not include them in transaction

I do not know if the issue is in code or the paypal account settings. Paypal displays correctly the shipping cost, it displays the correct total (item price + shipping),
but in fact, the transactions includes only the item price, not the shipping costs.
I have been unable to find out what is wrong. if paypal can display it correctly, why cant it include it properly in the transaction ?
here is the request sent to paypal:
$padata = '&CURRENCYCODE='.urlencode($PayPalCurrencyCode).
'&PAYMENTACTION=Sale'.
'&ALLOWNOTE=1'.
'&PAYMENTREQUEST_0_CURRENCYCODE='.urlencode($PayPalCurrencyCode).
'&PAYMENTREQUEST_0_AMT='.urlencode($TotalPrice).
'&PAYMENTREQUEST_0_ITEMAMT='.urlencode($ItemTotalPrice).
'&L_PAYMENTREQUEST_0_QTY0='. urlencode($ItemQty).
'&L_PAYMENTREQUEST_0_AMT0='.urlencode($ItemPrice).
'&PAYMENTREQUEST_0_SHIPPINGAMT='.urlencode($deliveryCost).
'&L_PAYMENTREQUEST_0_NAME0='.urlencode($ItemName).
'&L_PAYMENTREQUEST_0_NUMBER0='.urlencode($ItemNumber).
'&AMT='.urlencode($ItemTotalPrice).
'&RETURNURL='.urlencode($PayPalReturnURL ).
'&CANCELURL='.urlencode($PayPalCancelURL);
The param for shipping that I used is :
PAYMENTREQUEST_0_SHIPPINGAMT
is it correct ? is a complementary one needed ?
Are you supplying all of your PAYMENTREQUEST_0_* and L_PAYMENTREQUEST_0_* variables in your DoExpressCheckoutPayment call as well as your SetExpressCheckout call?
SetExpressCheckout will control what the buyer sees when they go to check out on PayPal. DoExpressCheckoutPayment will control what the buyer is actually charged for. Therefore, if you want your shipping charge to be included in the transaction, you need to make sure that it's included in both calls.
for the records, correct params for DoExpressCheckoutPayment :
$padata = '&TOKEN='.urlencode($token).
'&PAYERID='.urlencode($playerid).
'&PAYMENTACTION='.urlencode("SALE").
'&PAYMENTREQUEST_0_CURRENCYCODE='.urlencode($PayPalCurrencyCode).
'&PAYMENTREQUEST_0_SHIPPINGAMT='.urlencode($deliveryCost).
'&PAYMENTREQUEST_0_AMT='.urlencode($TotalPrice).
'&PAYMENTREQUEST_0_ITEMAMT='.urlencode($ItemTotalPrice).
'&CURRENCYCODE='.urlencode($PayPalCurrencyCode);

How to pass item_number to IPN when using Adaptive Payment API call to make pay request on Paypal?

I am using adaptive api to make a chained payment. The code looks
ChainedPay chainedPay = new ChainedPay(numberOfReceivers);
//set values (such as return url, cancel url, ipn url etc for the chainedPay object
....
Receiver primaryReceiver = new Receiver();
// set the receiver's value such as amount etc.
...
chainedPay.setPrimaryReceiver(primaryReceiver);
Receiver rec1 = new Receiver();
//set the second receiver's value
...
chainedPay.addToSecondaryReceivers(rec1);
//Make the request
chainedPay.makeRequest(); like this:
I do get the IPN message back when the payment is approved. But I want to be able to send a value such as a transactionId that exists in my system in the pay request, and have the IPN post it back to me, so I can look up the transaction by its id in my ipn listener, and use that information to deliver digital good to the user. I can't figure out where to set that value in the pay request.
Before using adaptive payment api call, if I want to pass the transaction id to the IPN, I would set it in the item_number field in a field in the form of the buy button and that would get passed through. Is there something similar in the adaptive api?
Thanks,
Tim
Try using the trackingid parameter. I am using the XML version and I pass it as follows
sRequest.Append("</trackingId>");
sRequest.Append(trackingID);
sRequest.Append("</trackingId>"); You may get a property as tracking id in PayRequest class.
I am passing the orderId via the trackingId field in the PayRequest
Ex:
PayRequest payRequest = new PayRequest(requestEnvelope, actionType, cancelUrl, currencyCode, receiverList, returnUrl);
payRequest.ipnNotificationUrl = System.Configuration.ConfigurationManager.AppSettings["PaypalNotifyUrl"];
payRequest.trackingId = orderId.ToString();
Then in the IPN handler, I retrieve it from the Request object.