Can't get my head around PayPal payment response errors or at least warnings. I am Australian developer (at least I am located in Australia and using AUD as a currency).
Could you please tell me why if the sandbox user has insufficient funds the transaction has a positive (valid) response on the request for payment?
So I have user_A who is buyer and a seller_user. user_A has 0AUD and makes a transaction of 20AUD of recurring payments and the response is successful??? Why?
What is the way to get to know that user doesn't have sufficient funds for the transaction?
gem: paypal-recurring
rails: 3.2.14
location: Australia
====== Controller action for redirecting to checkout url
ppl = PayPal::Recurring.new(
return_url: paypal_confirm_url(:plan_id => params[:plan_id], :user_id => current_user.id),
cancel_url: paypal_no_checkout_url,
description: "Starter",
amount: 15,
currency: "AUD"
)
response = ppl.checkout
if response.valid?
redirect_to response.checkout_url
else
redirect_to :back
end
==== Controller action after confirmation
ppr = PayPal::Recurring.new(
token: params[:token],
payer_id: params[:PayerID],
description: plan.name,
amount: plan.value,
currency: "AUD",
period: :monthly,
start_at: Time.zone.now,
frequency: 1
)
response = ppr.request_payment
if response.errors.any?
flash.keep[:error] = "Something went wrong please contact paypal or ask our development team: team.grapple1#gmail.com"
return false
end
response = ppr.create_recurring_profile
paypal_recurring_profile_token = response.profile_id # response.profile_id = nil????
save!
All PayPal sandbox accounts have a dummy bank account attached with unlimited funds. So when the PayPal account has $0, it just pulls from that "bank". For an insufficient funds error to occur, you would need to turn on negative testing somehow, though I think that produces errors based on trigger AMT variables. For classic APIs, I recommend just having your code look for an ACK response containing Success and treating the rest as an exception (perhaps printing out RESPMSG as a customer notice, though sometimes you'll want to replace that with your own error messaging)
Related
We are experiencing a problem where we have incurred all request
Request:
https://maps.googleapis.com/maps/api/directions/json?key=****&units=metricmode=driving&origin=-18.953220736126821,-48.24894517816412&destination=-48.2786408,-18.9218197&
Response:
error_message "You have exceeded your daily request quota for this API."
routes []
status "OVER_QUERY_LIMIT"
Our metrics haven't reported any issues. I am curious how and why these errors are being created.
My account is new and is not in production, we're just testing and ours metrics indicate 22 requests...
I'm following documentation for testing Braintree settlement status:
https://developers.braintreepayments.com/reference/general/testing/php#settlement-status
Doc says:
$result = Braintree_Test_Transaction::settle($sale_result->transaction->id);
$result->success
# true
$result->transaction->status
# Braintree_Transaction::SETTLED
I was testing with VISA card.
So expected result is transaction status "settled" (Braintree_Transaction::SETTLED).
Actual result is transaction status "settling" (Braintree_Transaction::SETTLING)
It's not a big deal but still I would be expecting SETTLED as stated in the documentation.
Anyone having same experience testing \Braintree\Test\Transaction::settle($transactionId) ?
Full disclosure: I work at Braintree. If you have any further questions, feel free to contact support.
While I can't personally recreate this behavior, I could imagine the gateway returning SETTLING rather than blocking until the settlement completes. Once the settle() call has returned, you can call
Braintree\Transaction::find($sale_result->transaction->id)
and inspect the status of that transaction response object to see if the settlement has been completed.
Paypal provides GetTransactionDetails API call to get the transaction status of a transaction. But it requires TRANSACTIONID as mandatory parameter which is transaction id assigned by Paypal to this transaction.
This TRANSACTIONID is returned by Paypal after completion of the payment. But in scenarios when the customer has made the payment and is returning to merchant page and the network is disrupted, the merchant won't be able to get the status of payment as well as the transaction id of paypal. How would the merchant be able to get the transaction later using API call? Is there any way to get the status using the transaction Id of the merchant?
You can pass your own invoice id in the variable "INVNUM" and then run the "TransactionSearch" API to get the details by passing the "INVNUM" which will give you the response with PayPal's transaction id (if transaction would have been gone thru ).
And once you get the transaction id for PayPal , run the "GetTransactionDetails" API to the detailed information . I have included the sample request and response where in the first api I used my own invnum to fetch the details and then using the PayPal's txn id in response I fetched the complete detail.
NVP Request:
USER=us-XXXX&PWD=XXXX&SIGNATURE=XXXX&VERSION=109.0&METHOD=TransactionSearch&STARTDATE=2015-08-08T00:00:00Z&TRANSACTIONCLASS=All&INVNUM=MyOWNID123456
NVP Response:
L_TIMESTAMP0=2015-08-20T16:43:10Z
L_TIMEZONE0=GMT
L_TYPE0=Payment
L_NAME0=John Test
L_TRANSACTIONID0=33407257W5286551J
L_STATUS0=Completed
L_AMT0=0.01
L_CURRENCYCODE0=USD
L_FEEAMT0=-0.01
L_NETAMT0=0.00
TIMESTAMP=2015-08-20T16:44:22Z
CORRELATIONID=7247ad390a76
ACK=Success
VERSION=109.0
BUILD=000000
NVP Request:
USER=XXXX&PWD=XXXX&SIGNATURE=XXX&VERSION=109.0&METHOD=GetTransactionDetails&TRANSACTIONID=33407257W5286551J
NVP Response:
RECEIVERBUSINESS=XXXXX
RECEIVEREMAIL=XXXXXX
RECEIVERID=XXXXX
PAYERID=RPP8F58J274JG
PAYERSTATUS=unverified
COUNTRYCODE=US
ADDRESSOWNER=PayPal
ADDRESSSTATUS=None
INVNUM=MyOWNID123456
SALESTAX=0.00
SHIPAMOUNT=0.00
SHIPHANDLEAMOUNT=0.00
TIMESTAMP=2015-08-21T04:03:50Z
CORRELATIONID=db0509e83df7c
ACK=Success
VERSION=109.0
BUILD=000000
FIRSTNAME=John
LASTNAME=Test
TRANSACTIONID=33407257W5286551J
RECEIPTID=5098-8700-1518-0878
TRANSACTIONTYPE=webaccept
PAYMENTTYPE=instant
ORDERTIME=2015-08-20T16:43:10Z
AMT=0.01
FEEAMT=0.01
TAXAMT=0.00
CURRENCYCODE=USD
PAYMENTSTATUS=Completed
PENDINGREASON=None
REASONCODE=None
PROTECTIONELIGIBILITY=Ineligible
PROTECTIONELIGIBILITYTYPE=None
L_QTY0=1
L_TAXAMT0=0.00
L_CURRENCYCODE0=USD
L_TAXABLE0=false
I am doing some development using payflow api
I created test only payflow account. (Transaction Process Mode = Test)
My program uses secure token with hosted check out page.
When I submit my credit card info in the hosted checkout page, the error URL of my program gets called with error code "12" transaction declined.
I try manual testing the payment by going to Paypal Manager-->Virtual Terminal-->Single Transaction. I filled up all the info (along with actual credit card details) and I got the same error - Result Code = 12. Response Message = Declined.
But when I click on "Transaction Details" --> Response Message (Declined) "Click here for fraud details"; it says "Status" as "Passed".
I tried this for both transaction type Sale and Authorize.
So is the error code 12 and Response message "Declined" is because of "Transaction Mode" is Test?
some extra info:
TYPE = 'S'
PREFPSMSG = 'No Rules Triggered'
RESPMSG = 'Declined'
RESULT = '12'
Payflow and Braintree (I believe) give you different results based on what amount so that you can test decline, etc. Make sure your test amount is less than $1001.
Currently I have a script that checks to make sure that a test card was not submitted in production (since Authorize.net accepts test credit cards in live mode) and I add an error message to the credit card number if the one submitted is in the Test_Credit_Cards array like so:
TEST_CREDIT_CARDS = ['370000000000002', '6011000000000012', '4007000000027', '4012888818888']
validate :not_a_test_credit_card
def not_a_test_credit_card
self.errors[:cc_number] << "number is invalid!" if TEST_CREDIT_CARDS.include?(cc_number) and Rails.env.production?
end
Now on the front end the error message appears like so:
Credit card cc number is invalid!
Is there anyway to change the message to read Credit Card number is invalid! I just want to remove the cc portion from the message.
First, remove the number from the error message:
self.errors[:cc_number] << "is invalid!" if TEST_CREDIT_CARDS.include?(cc_number) and Rails.env.production?
Next, put a translation for cc_number in config/locales/en.yml:
en:
activerecord:
attributes:
credit_card:
cc_number: "number"
I prefer this answer over Anthony Alberto's answer for three reasons:
It is always a good idea to use ActiveRecord existing translation engine.
This way, cc_number will be translated to number whenever you add errors on it.
It is not true that the error is on the CreditCard instance itself, it is specifically related to the cc_number field.
That should do it :
self.errors[:base] << "number is invalid!" if TEST_CREDIT_CARDS.include?(cc_number) and Rails.env.production?
base refers to the object as a whole, not a specific attribute.