Testing Chargebacks/Dispute with IPN in the PayPal Sandbox - paypal

Is there any way to go to test Chargebacks/Disputes on the PayPal Sandbox test site?
I try to use the resolution center to create new cases both through the normal method of disputing a charge and through the sandbox specific "Create or Resolve Case" section of the Resolution Center.
Either way I do it, I can only ever get the disputes into a status of "Being Reviewed By PayPal". No IPN notifications are sent out.
This support article details the expected steps I'm hoping to emulate in the sandbox environment: https://ppmts.custhelp.com/app/answers/detail/a_id/622/kw/Dispute

What you'll need to do is create your own IPN simulator to test this. You can make a basic HTML form with the action set to your IPN URL and hidden fields that match the names/values you expect to get from an IPN.
This way you can load your test in a browser and submit it to your IPN listener. You'll be able to see the results on screen which can help with troubleshooting.
Keep in mind that when testing this way the data is not coming from PayPal's server so the IPN will be unverified. You'll need to make sure your code logic handles that.
Here are some samples of IPN's you'd get when a chargeback occurs so you can see what you should expect and setup your simulator accordingly.
New Case
txn_type = new_case
payment_date = 13:40:52 Aug 05, 2013 PDT
case_id = PP-002-576-509-683
receipt_id = 4674-2219-3481-3741
case_type = chargeback
business = payments#domain.com
verify_sign = AeD56uUedZzgp83xxTHMkZtMZ9FVAzvpMwl6OHUf9CNvlvgA2P0mbcwP
payer_email = 9FE47613HE5558457#dcc.paypal.com
txn_id = 0PC8014855508203X
case_creation_date = 18:40:23 Sep 04, 2013 PDT
receiver_email = payments#domain.com
payer_id = RZ3LX555U646Q
receiver_id = M5VRA555CSK6
reason_code = non_receipt
custom =
charset = windows-1252
notify_version = 3.7
ipn_track_id = 2842c24f40ac
Reversal
mc_gross = -1972.86
protection_eligibility = Ineligible
payer_id = RZ3LX555U646Q
address_street = N/A
payment_date = 18:42:00 Sep 04, 2013 PDT
payment_status = Reversed
charset = windows-1252
address_zip = 00000
first_name = Tester
mc_fee = -44.74
address_country_code = US
address_name = Tester Testerson
notify_version = 3.7
reason_code = chargeback
custom =
business = payments#usbswiper.com
address_country = United States
address_city = NA
verify_sign = Ai1PaghZh5FmBLCDCTQpwG8jB264ABWpa3tbhFljkaPnVj1L9ip5EwyS
parent_txn_id = 0PC8014555008203X
txn_id = 0PC8014855508203X
payment_type = instant
last_name = Testerson
address_state = NA
receiver_email = payments#domain.com
payment_fee = -44.74
receiver_id = M5VRA555CSK6
item_name = PayPal POS Web Order
mc_currency = USD
item_number =
residence_country = US
receipt_id = 4674-2219-3481-3741
handling_amount = 0.00
transaction_subject =
payment_gross = -1972.86
shipping = 100.00
ipn_track_id = f456d076de1ff

Related

Sending email with Classic ASP through Godaddy

I'm trying to send email using Classic ASP from my website at Godaddy. Unfortunately, the cod I have from 10-15 years ago doesn't work (imagine that! lol). Here's the code. Can someone tell me what has changed since then? desperately await your reply. Thank you!
Set cdoConfig = CreateObject("CDO.Configuration")
With cdoConfig.Fields
.Item(cdoSMTPConnectionTimeout) = 10
.Item(cdoSMTPAuthenticate) = false
.Item(cdoSendUserName) = "email#mywebsite.com"
.Item(cdoSendPassword) = "MyPassword"
.Item(cdoURLProxyServer) = "server:25"
'.Item(cdoSendUsingMethod) = cdoSendUsingPickup
.Item(cdoSendUsingMethod) = cdoSendUsingPort
.Item(cdoSMTPServer) = "relay-hosting.secureserver.net"
.Item(cdoURLGetLatestVersion) = True
.Update
End With
'Create mail object
Set cdoMessage = CreateObject("CDO.Message")
'Apply the settings to the message object then send the email
With cdoMessage
Set .Configuration = cdoConfig
.From = "Support (email#mywebsite)"
.To = "The User (user#email.com)"
.BCC = ""
.Subject = "This is a test email."
.TextBody = "This is a test email. If it were a real email there would be some blah blah blah here! This concludes the test of the Godaddy email message."
.Send
End With
'Cleanup mail objects
Set cdoMessage = Nothing
Set cdoConfig = Nothing
Ok folks. This is for the people that need a guiding hand from time to time. However, make sure you enter the right username and password. When hosting on Godaddy you could have up to three different usernames and passwords. You have your Godaddy account username and password (that's not it!), you have a username and password for Plesk (that's not it either!). Then you have a username and password for your primary website (that's the one you want!). Even though you might have several different websites under your hosting, only one will be the primary. Mine was for the email and password that are associated with that prime website. Once you get this code posted you should be good to go. However, you might have to wait a while in order for it to start working. For me it took about 8 hours for the DNS to catch hold of what I was doing and start sending my emails through. Once it did though, now it works great! Enjoy!
Dim objNewMail
'Your email information
Set objNewMail = Server.CreateObject("CDO.Message")
objNewMail.From = "your-email#this-website.com"
objNewMail.Cc = "your-email#this-website.com"
objNewMail.To = "send-to#their-email.com"
objNewMail.Subject = "This is a test email"
objNewMail.TextBody = "this is a test email"
' GoDaddy SMTP Settings
objNewMail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusing")=2
objNewMail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver")="relay-hosting.secureserver.net"
objNewMail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport")=25
objNewMail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = 60
objNewMail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/cdoSendUserName") = "your-primary-website-username"
objNewMail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/cdoSendPassword") = "your-primary-website-password"
objNewMail.Configuration.Fields.Update
objNewMail.Send
'After the Send method, NewMail Object become Invalid
Set objNewMail = Nothing

Not receiving ipn response from PayPal

Im having problems with PayPal and IPN on my website and have tried loads of things with no joy.
What i am attempting to do:
Receive notification of payment from PayPal and then update database with details from variables.
Whats working:
Using the IPN simulator from PayPal sandbox to simulate a transaction and sending the information to my listener WORKS and database gets updated.
purchasing items through the website works on sandbox and with out sandbox.
what does not work:
after purchase on website, listener does not receive information back from PayPal either using sandbox or normal and there for database does not get updated.
What i am using:
I am using simpleCartjs for my cart
Listener file is:
$p = new paypal_class;
if ($p->validate_ipn() && !empty($p->ipn_data['payment_status']) && $p->ipn_data['payment_status'] == 'Completed') {
$mc_gross = $_POST['mc_gross'];
$payer_id = $_POST['payer_id'];
$payment_date = $_POST['payment_date'];
$first_name = $_POST['first_name'];
$last_name = $_POST['last_name'];
$payer_email = $_POST['payer_email'];
$payment_status = $_POST['payment_status'];
$payer_status = $_POST['payer_status'];
$address_name = $_POST['address_name'];
$address_country = $_POST['address_country'];
$address_zip = $_POST['address_zip'];
$address_state = $_POST['address_state'];
$address_city = $_POST['address_city'];
$address_street = $_POST['address_street'];
$mc_shipping = $_POST['mc_shipping'];
$mc_currency = $_POST['mc_currency'];
$ipn_track_id = $_POST['ipn_track_id'];
$stmt = $con->prepare("INSERT into orders (mc_gross, payer_id, payment_date, first_name, last_name, payer_email, payment_status, payer_status, address_name, address_country, address_zip, address_state, address_city, address_street, mc_shipping, mc_currency, ipn_track_id) VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)");
$stmt->bind_param("sssssssssssssssss", $mc_gross, $payer_id, $payment_date, $first_name, $last_name, $payer_email, $payment_status, $payer_status,
$address_name, $address_country, $address_zip, $address_state,
$address_city,
$address_street, $mc_shipping, $mc_currency, $ipn_track_id);
$stmt->execute();
$stmt->close();
}
Does anyone know what could be the issue please? cant seem to get this working no matter what i try. I have IPN enabled in my business paypal account.
Thank you

PayPal Sandbox new certificate giving Timeout processing request error

PayPal Sandbox upgraded to provide more secured API certificate with SHA-256, 2048 bit. This was verified using the openssl command provided in
https://www.paypal-knowledge.com/infocenter/index?page=content&widgetview=true&id=FAQ1915&viewlocale=en_US
Now when I tested using the existing old (SHA-1, 1024 bit) API certificate on sandbox, it worked properly.
But when a new API certificate (SHA-256, 2048 bit) was created and used for testing on sandbox then it started giving error response from sandbox,
ACK=Failure
L_ERRORCODE0=10001
L_SHORTMESSAGE0=Internal Error
L_LONGMESSAGE0=Timeout processing request
Please anyone can point out what might be the cause of this error?
For reference PayPal request (modified) sent to sandbox endpoint,
METHOD = SetExpressCheckout
RETURNURL = https://local/ReturnPage
CANCELURL = https://local/ProcessCancel
ALLOWNOTE = 0
LOGOIMG = https://local/img/logo.png
ADDROVERRIDE = 1
EMAIL = xxx#xxx.com
SOLUTIONTYPE = Mark
BUTTONSOURCE = BtnSrc
BRANDNAME = My Brand
PAYMENTREQUEST_0_SHIPTONAME = Mr Joshi
PAYMENTREQUEST_0_SHIPTOSTREET = 300 Oxford Street
PAYMENTREQUEST_0_SHIPTOCITY = London
PAYMENTREQUEST_0_SHIPTOZIP = TE45 6ST
PAYMENTREQUEST_0_SHIPTOCOUNTRYCODE = GB
PAYMENTREQUEST_0_SHIPTOPHONENUM = 09824112345
NOSHIPPING = 1
PAYMENTREQUEST_0_PAYMENTACTION = Sale
PAYMENTREQUEST_0_CURRENCYCODE = GBP
L_PAYMENTREQUEST_0_NAME0 = 101-Jeans
L_PAYMENTREQUEST_0_DESC0 = Jeans
L_PAYMENTREQUEST_0_AMT0 = 59.0
L_PAYMENTREQUEST_0_QTY0 = 1
L_PAYMENTREQUEST_0_NAME1 = Other payments
L_PAYMENTREQUEST_0_DESC1 = Other payments
L_PAYMENTREQUEST_0_AMT1 = -8.02
L_PAYMENTREQUEST_0_QTY1 = 1
PAYMENTREQUEST_0_ITEMAMT = 50.98
PAYMENTREQUEST_0_AMT = 53.97
PAYMENTREQUEST_0_SHIPPINGAMT = 2.99
MAXAMT = 53.97
VERSION = 112.0
I have double verified the API username and API passowrd. As well as the API certificate. Even re-created the API certificate from cert_key_pem.txt obtained by downloading it from sandbox account.

Implementing Paypal IPN with ASP vNext

I'm using IPN Simulator to send the requests:
https://developer.paypal.com/developer/ipnSimulator
When I receive the IPN, I make a POST to paypal with the same data, adding &cmd=_notify-validate at the end. Problem is I always receive "INVALID" response. Is it because of IPN simulator or am I posting a wrong request ?
This is my IPN Controller:
[HttpPost]
public string IPN()
{
bool useSandbox = true;
StringBuilder to_send = new StringBuilder();
foreach (string key in Request.Form.Keys)
{
if (to_send.ToString().Equals(""))
to_send.AppendFormat("{0}={1}", key, Request.Form[key]);
else
to_send.AppendFormat("&{0}={1}", key, Request.Form[key]);
}
string paypalUrl = useSandbox ? "https://www.sandbox.paypal.com/cgi-bin/webscr"
: "https://www.paypal.com/cgi-bin/webscr";
HttpWebRequest req = (HttpWebRequest)WebRequest.Create(paypalUrl);
req.Method = "POST";
req.ContentType = "application/x-www-form-urlencoded";
to_send.AppendFormat("&{0}={1}", "cmd", "_notify-validate");
string strRequest = to_send.ToString();
req.ContentLength = strRequest.Length;
string response = "";
using (StreamWriter streamOut = new StreamWriter(req.GetRequestStream(), System.Text.Encoding.ASCII))
{
streamOut.Write(strRequest);
streamOut.Close();
using (StreamReader streamIn = new StreamReader(req.GetResponse().GetResponseStream()))
{
response = streamIn.ReadToEnd();
}
}
}
Here's what I receive from paypal :
> payment_type: instant
payment_date: Sun Aug 09 2015 12:23:13 GMT+0300 (GTB Daylight Time)
payment_status: Completed
address_status: confirmed
payer_status: verified
first_name: John
last_name: Smith
payer_email: buyer#paypalsandbox.com
payer_id: TESTBUYERID01
address_name: John Smith
address_country: United States
address_country_code: US
address_zip: 95131
address_state: CA
address_city: San Jose
address_street: 123 any street
business: seller#paypalsandbox.com
receiver_email: seller#paypalsandbox.com
receiver_id: seller#paypalsandbox.com
residence_country: US
item_name: something
item_number: AK-1234
quantity: 1
shipping: 3.04
tax: 2.02
mc_currency: USD
mc_fee: 0.44
mc_gross: 12.34
mc_gross1: 12.34
txn_type: web_accept
txn_id: 363750782
notify_version: 2.1
custom: xyz123
invoice: abc1234
test_ipn: 1
verify_sign: AUxvCDK2PEEhNsHhVyUQ8Y-mDqfQARYxDdlEIxTy83GhdfASQp4iG0Rj
And here's what I'm posting back:
payment_type=instant&payment_date=Sun Aug 09 2015 12:23:13 GMT+0300 (GTB Daylight Time)&payment_status=Completed&address_status=confirmed&payer_status=verified&first_name=John&last_name=Smith&payer_email=buyer#paypalsandbox.com&payer_id=TESTBUYERID01&address_name=John Smith&address_country=United States&address_country_code=US&address_zip=95131&address_state=CA&address_city=San Jose&address_street=123 any street&business=seller#paypalsandbox.com&receiver_email=seller#paypalsandbox.com&receiver_id=seller#paypalsandbox.com&residence_country=US&item_name=something&item_number=AK-1234&quantity=1&shipping=3.04&tax=2.02&mc_currency=USD&mc_fee=0.44&mc_gross=12.34&mc_gross1=12.34&txn_type=web_accept&txn_id=363750782&notify_version=2.1&custom=xyz123&invoice=abc1234&test_ipn=1&verify_sign=AUxvCDK2PEEhNsHhVyUQ8Y-mDqfQARYxDdlEIxTy83GhdfASQp4iG0Rj&cmd=_notify-validate
Edit 1:
I tried changing the encoding to UTF-8 as it says on paypal documentation, but it still doesn't work :
Ensure that you use the same character encoding for your response string as the encoding specified in the charset field of the original IPN message. When testing using the IPN Simulator, the character encoding will always be UTF-8.
byte[] byteArray = Encoding.UTF8.GetBytes(strRequest);
string response = "";
using (BinaryWriter streamOut = new BinaryWriter(req.GetRequestStream(), System.Text.Encoding.UTF8))
{
streamOut.Write(byteArray, 0, byteArray.Length);
streamOut.Close();
using (StreamReader streamIn = new StreamReader(req.GetResponse().GetResponseStream()))
{
response = streamIn.ReadToEnd();
}
}
Is it possible that the variables in Request.Form are not in the order they have been sent ?
cmd=_notify-validate is required to be preceding the original variables not succeeding them, you may want make some adjustment in your to_send StringBuilder code block to something like this:
StringBuilder to_send = new StringBuilder();
to_send.Append("cmd=_notify-validate");
foreach (string key in Request.Form.Keys)
{
to_send.AppendFormat("&{0}={1}", key, Request.Form[key]);
}
string strRequest = to_send.ToString();
p.s Refer here for IPN trouble shooting tips , this would be quite helpful as most of the issues have been covered in there

CreateRecurringPaymentsProfile giving Error 11502: Invalid Token

I keep getting the Invalid Token Error when i call the CreateRecurringPaymentsProfile NVP API.
Please find the sequence of my API calls below:
SetExpressCheckout
METHOD = SetExpressCheckout
VERSION = 98
PWD = <pwd>
USER = <user>
SIGNATURE = <signature>
ReturnUrl = http://google.com
CANCELURL = http://google.com
PAYMENTREQUEST_0_PAYMENTACTION = Authorization
PAYMENTREQUEST_0_AMT = 100.00
PAYMENTREQUEST_0_CURRENCYCODE = USD
L_PAYMENTREQUEST_0_NAME0 = Item1
L_PAYMENTREQUEST_0_QTY0 = 1
L_PAYMENTREQUEST_0_AMT0 = 100.00
PAYMENTREQUEST_0_SELLERPAYPALACCOUNTID = rahul.katikineni#sap.com
LOCALECODE = US
L_BILLINGTYPE0 = RecurringPayments
L_BILLINGAGREEMENTDESCRIPTION0 = SameEveryTime
I get back a token with ACK=*Success* as response. I then navigate to the paypal website using the URL [https://www.sandbox.paypal.com/webscr&cmd=_express-checkout&token=token] and login with a paypal account and click on "Agree and Continue".
After agreeing and successfully redirecting to the redirect URL, I make the GetExpressCheckoutDetails API call with the following parameters
METHOD = GetExpressCheckoutDetails
VERSION = 98
PWD = <pwd>
USER = <user>
SIGNATURE = <signature>
TOKEN = <token from the SetExpressCheckout response>
After successfully getting the the payer details as response, i make the DoExpressCheckoutPayment API call
METHOD = DoExpressCheckoutPayment
VERSION = 98
PWD = <pwd>
USER = <user>
SIGNATURE = <signature>
TOKEN = <token from the SetExpressCheckout response>
PAYERID = <payer ID from the GetExpressCheckoutDetails response>
PAYMENTREQUEST_0_AMT = 100
PAYMENTREQUEST_0_PAYMENTACTION = Sale
PAYMENTREQUEST_0_CURRENCYCODE = USD
L_PAYMENTREQUEST_0_NAME0 = Item1
L_PAYMENTREQUEST_0_QTY0 = 1
L_PAYMENTREQUEST_0_AMT0 = 100.00
PAYMENTREQUEST_0_SELLERPAYPALACCOUNTID = rahul.katikineni#sap.com
I now make the CreateRecurringPaymentsProfile API call
METHOD = CreateRecurringPaymentsProfile
VERSION = 98
PWD = <pwd>
USER = <user>
SIGNATURE = <signature>
TOKEN = <token from the SetExpressCheckout response>
PAYERID = <payer ID from the GetExpressCheckoutDetails response>
DESC = SameEveryTime
BILLINGPERIOD = Month
BILLINGFREQUENCY = 1
PROFILESTARTDATE = 2013-05-16T00:00:00Z
MAXFAILEDPAYMENTS = 1
AMT = 100.00
CURRENCYCODE = USD
L_PAYMENTREQUEST_0_NAME0 = Item1
L_PAYMENTREQUEST_0_QTY0 = 1
L_PAYMENTREQUEST_0_AMT0 = 100.00
AUTOBILLAMT = AddToNextBilling
I keep getting the following response
TIMESTAMP = 2013-04-17T05:31:24Z
CORRELATIONID = d2c1d30c1d31
ACK = Failure
VERSION = 98
BUILD = 5650305
L_ERRORCODE0 = 11502
L_SHORTMESSAGE0 = Invalid Token
L_LONGMESSAGE0 = The token is invalid
L_SEVERITYCODE0 = Error
I have tried looking for a solution in many forums but could not figure out if i have missed any parameters.
Can anyone help me on this?
Thanks in advance,
Rahul
This error returned by Paypal is vague. Most common reason for this error is discrepancy between BillingDescription value in SetExpressCheckout call and ScheduleDEtails.Description in CreateRecurringprofile call. Make sure these two are exactly the same for this to work.
Eg:
public CreateRecurringPaymentsProfileResponseType createRecurringProfile(string tokenin){
var scheduleDetails = new ScheduleDetailsType();
scheduleDetails.PaymentPeriod = paymentPeriod;
scheduleDetails.Description = "RecurringBilling";
}
public SetExpressCheckoutResponseType setExpressCheckout()
{
....
var billingAgreement = new BillingAgreementDetailsType();
billingAgreement.BillingAgreementDescription = "RecurringBilling";
billingAgreement.BillingType = BillingCodeType.RECURRINGPAYMENTS;
billingAgreement.PaymentType = MerchantPullPaymentCodeType.ANY;
ecDetails.BillingAgreementDetails.Add(billingAgreement);
...
}