Bug with negative amounts in PayPal API - paypal

I'm trying to use a negative amount with the PayPal Adaptive Payments API. To start with, this seems to work:
'item' => [
{
'itemPrice' => '25.00',
'name' => 'Cryptex - 16Gb USB Drive',
'price' => '25',
'itemCount' => 1
},
{
'quantity' => 1,
'name' => 'Special Discount',
'price' => '-2.50'
},
{
'itemPrice' => '5.00',
'name' => 'Shipping',
'price' => '5.00',
'itemCount' => 1
}
]
Here is an example of what I see after submitting this as JSON, and updating the items:
As you can see, the price IS correct ... yet there is no sign of the discounted amount? Its obviously taking it into account - otherwise the price would have been £30, not £27.50 (which is after the £2.50 discount)
What gives? Is this a bug in PayPals system?
FWIW, the emails are also broken - they don't show the discount amount at all.
UPDATE: I've opened a ticket with PayPal tech support, as I'm pretty sure this is a bug with their system, and not something that can be fixed this end :( Damn annoying!
UPDATE 2: Reply from PayPal:
PayPal Adaptive Payments do not support negative item values. Since you did not pass the <itemPrice> in your API Call, the system did not throw the following error message:
[errorId] => 580022
[domain] => PLATFORM
[subdomain] => Application
[severity] => Error
[category] => Application
[message] => Invalid request parameter: itemPrice cannot be negative
I can see that the following was submitted to PayPal:
<item>
<name>Special Discount</name>
<identifier></identifier>
<price>-2.50</price>
<itemPrice></itemPrice>
<itemCount></itemCount>
<any>[quantity: null]</any>
</item>
This object is basically incomplete and in order to apply discounts, you should apply them > onto the price for the main item and then submit it to PayPal.
I'm really not sure what they're suggestion I do? An example cart, would be:
Item 1 - £10
Item 2 - £20
Item 3 - £50
Item 4 - £10
Delivery - £5
Total - £95
As an encouragement, we sometimes will offer coupons... so it could be "£10 off orders over £50". So in the above case above, it would drop the overall price to £85.
I'm really not sure what they are suggesting as an alternative?

Interesting. Normal payments don't have that restriction (I pass a negative amount item just like what you describe on a frequent basis).
What they're telling you to do is take the discount off another item. So your example cart with that discount would be
Item 1 - £10
Item 2 - £20
Item 3 - £40 <-- Removed £10 discount
Item 4 - £10
Delivery - £5
Total - £85 <-- total reflects this

Related

paypal trial recurring payment not getting started

I have created a paypal recurring payment with a trial period of 1 month. I am testing with my sandbox account.
After completing 1 payment I can see in my sandbox merchant account that the recurring payment has been created. But it's displaying: "recurring cycle remaining 1 month" and I have received $0. I mean the recurring payment has been started, but I am not receiving the money.
Is that paypal's fault or is there a problem with my code?
Well I am using a CMS(Social Eninge) . Paypal has been integrated here already . So I am just modifying it. Here is the parameters I am sending.
// This Portion to display the payment summery :
$params['driverSpecificParams']['PayPal'] = array(
'ITEMCATEGORY'=> 'Digital',
'AMT' => $params['price'],
'NAME' => $package->title,
'DESC' => $desc,
'ITEMS' => array(
array(
'NAME' => $package->title,
'AMT' => $params['price'],
'QTY' => 1,
),
),
'BILLINGTYPE' => 'RecurringPayments',
'BILLINGAGREEMENTDESCRIPTION' => $desc,
);
// And this portion for payment subscription.
$rpData = array(
'TOKEN' => $params['token'],
'PROFILEREFERENCE' => $order->order_id,
'PROFILESTARTDATE' => $data['TIMESTAMP'],
'DESC' => $desc, //Item Description
'BILLINGPERIOD' => ucfirst($package->recurrence_type),
'BILLINGFREQUENCY' => $package->recurrence,
'INITAMT' => 0 ,
'TRIALBILLINGPERIOD' => ucfirst($package->recurrence_type),
'TRIALBILLINGFREQUENCY' => $package->recurrence,
'TRIALTOTALBILLINGCYCLES' => 1,
'TRIALAMT' => $_SESSION["price"],
'AMT' => $package->price,
'CURRENCYCODE' => $this->getGateway()->getCurrency(),
);
I would also like to know whether setting $0 for a few months in my trial period will work or not ?
Paypal displaying like this :
[1]: https://i.stack.imgur.com/mSxk1.png
Well, I have found my code is right. It's paypal's delay for few hours.
Also setting $0 for trial period works perfectly. Trial period automatically choose the starting interval. You need to pass for how many days ,months, year, or week you wanna offer trial and which price, it might be lower price or zero doesn't matters.Like I am offering 1st month free/some reduced price after that it will continue the normal price.

PayFlow PayPal recurring Payment EXPDATE Validation

Hi I have been trying to validate CC no., CVV no., EXPDATE of the users credit card for recurring billing in PayFlow. The main objective is to let the user have access to subscription products only if the credit card is valid.
I have been advised to check the card prior to creating the profile you could run a credit card verification ($0 authorization)
So I did it and I got [RESPMSG] => Verified
Here's my request and response messages:
Request
Array
(
[TRXTYPE] => A
[TENDER] => C
[PARTNER] => PayPal
[USER] => XXXXX
[PWD] => XXXXX
[AMT] => 0
[ACCT] => 5105105105105100
[EXPDATE] => 1218
[INVNUM] => PONUM1
[VERBOSITY] => HIGH
[BILLTOZIP] => 95031
)
Response
Array
(
[RESULT] => 0
[PNREF] => A11A8C1A41C0
[RESPMSG] => Verified
[AUTHCODE] => 992PNI
[AVSADDR] => X
[AVSZIP] => X
[HOSTCODE] => A
[PROCAVS] => U
[TRANSTIME] => 2015-11-22 23:30:52
[AMT] => 0.00
[ACCT] => 5100
[EXPDATE] => 1218
[CARDTYPE] => 1
[IAVS] => X
[PREFPSMSG] => No Rules Triggered
[POSTFPSMSG] => No Rules Triggered
)
Now my question is I haven't provided CVV2 and also Any future date as EXPDATE gets verified. Can you please explain how things are working here? Also how can I verify CC, CVV and EXPDATE ?
This is simply creating the profile without any initial payment. As such, it's not going to validate the card at all. Of course, the first payment attempted on the profile would fail.
If you want to check the card prior to creating the profile you could run a credit card verification ($0 authorization).
So run the card verification first, and then only if that is successful you would follow up with a call to create the profile.
Keep in mind that if you're working in the sandbox any credit card expiration and security code will be accepted as long as it's not expired. This is done in the sandbox to make testing quick and easy.
If you would like to force errors in the API response so you can test those cases, take a look at the PayFlow documentation on testing.
Yes in the Test mode any future date for EXPDATE will be fine as Andrew mentioned . If you are looking for CVV value to be returned as "N" in the test mode then you can adjust the CVV values according to the docs below .
https://developer.paypal.com/webapps/developer/docs/classic/payflow/integration-guide/#testing-card-security-code
NVP Request:
VENDOR=XXX&PARTNER=Paypal&USER=XXXX&PWD=XXXX&TRXTYPE[1]=A&TENDER[1]=C&VERBOSITY=HIGH&ACCT[16]=5105105105105100&EXPDATE[4]=1020&AMT=0.00&**CVV2[3]=400**&COMMENT1[23]=Global Test Transaction&FIRSTNAME[4]=John&LASTNAME[5]=Smith&STREET=49354 Main&CITY[7]=SanJose&STATE[2]=CA&ZIP[5]=94303&COUNTRY[2]=US
NVP Response:
RESULT=0
PNREF=A71C8A7EA028
RESPMSG=Verified
AUTHCODE=010101
AVSADDR=N
AVSZIP=N
CVV2MATCH=N
HOSTCODE=A
RESPTEXT=100
PROCAVS=I8
PROCCVV2=N
TRANSTIME=2015-11-23 20:05:55
FIRSTNAME=John
LASTNAME=Smith
AMT=0.00
ACCT=5100
EXPDATE=1020
CARDTYPE=1
IAVS=N
PREFPSMSG=No Rules Triggered
POSTFPSMSG=No Rules Triggered

Cannot get invoice in respose of CreateRecurringPaymentsProfile in paypal

My intention is to create a Recurring Profile and pass a company_id as custom parameter to be stored IPN database, where I can create a relation between payment and for which company it was done.
I have read that while creating Recurring Payment Profile to get some custom value in IPN database, you should pass it in PROFILEREFERENCE parameter and then retrieve it from rp_invoice_id in response.
I cannot get the desired output
My request:
$inputData = array(
'METHOD' => 'CreateRecurringPaymentsProfile',
'TOKEN' => $_GET['token'], //get from GetExpressCheckout
'PAYERID' => $billerInfo['PAYERID'], //from GetExpressCheckout response
'PROFILESTARTDATE' => date("Y-m-d h:i:s", strtotime("+5 seconds")), //2012-05-11T00:00:00Z #Billing date start, in UTC/GMT format
'DESC' => 'LeaveBuddy: subscription amount is $' . $bill .' for the provided service ($12 per user per year).', //#Profile description - same as billing agreement description
'BILLINGPERIOD' => 'Year', #Period of time between billings
'BILLINGFREQUENCY' => 1,#Frequency of charges
'AMT' => 10, //Todo: dynamically calculate the amt #The amount the buyer will pay in a payment period
'CURRENCYCODE' => 'USD',#The currency, e.g. US dollars
'COUNTRYCODE' => 'US',#The country code, e.g. US
'MAXFAILEDPAYMENTS' => '0',#Maximum failed payments before suspension of the profile
'PROFILEREFERENCE' => 'companyid=1', //my custom value
);
The response that I am getting is:
{"InstantPaymentNotification":{"id":"553db30b-ea1c-4f68-8b5d-4fe5cbdd56cb","notify_version":"3.8","verify_sign":"A--8MSCLabuvN8L.-MHjxC9uypBtAQZom1C7.mbS1Jv-J898ZO0eeOr9","test_ipn":"1","address_city":null,"address_country":null,"address_country_code":null,"address_name":null,"address_state":null,"address_status":null,"address_street":null,"address_zip":null,"first_name":"code","last_name":"booster","payer_business_name":null,"payer_email":"codebooster#gmail.com","payer_id":"XXXXXXXX","payer_status":"verified","contact_phone":null,"residence_country":"US","business":null,"item_name":null,"item_number":null,"quantity":null,"receiver_email":"boom#gmail.com","receiver_id":null,"custom":null,"invoice":null,"memo":null,"option_name1":null,"option_name2":null,"option_selection1":null,"option_selection2":null,"tax":"0.00","auth_id":null,"auth_exp":null,"auth_amount":null,"auth_status":null,"num_cart_items":null,"parent_txn_id":null,"payment_date":null,"payment_status":null,"payment_type":null,"pending_reason":null,"reason_code":null,"remaining_settle":null,"shipping_method":null,"shipping":"0.00","transaction_entity":null,"txn_id":"316859739","txn_type":"recurring_payment","exchange_rate":null,"mc_currency":null,"mc_fee":null,"mc_gross":10,"mc_handling":null,"mc_shipping":null,"payment_fee":null,"payment_gross":null,"settle_amount":null,"settle_currency":null,"auction_buyer_id":null,"auction_closing_date":null,"auction_multi_item":null,"for_auction":null,"subscr_date":null,"subscr_effective":null,"period1":null,"period2":null,"period3":null,"amount1":null,"amount2":null,"amount3":null,"mc_amount1":null,"mc_amount2":null,"mc_amount3":null,"recurring":null,"reattempt":null,"retry_at":null,"recur_times":null,"username":null,"password":null,"subscr_id":null,"case_id":null,"case_type":null,"case_creation_date":null,"created":"2015-04-27 03:54:51","modified":"2015-04-27 03:54:51"},"PaypalItem":[]}
So i cannot find any [rp_invoice_id] parameter here, and my invoice is also appearing null. Can any one tell me what I am missing?

Paypal REST API Stored Credit Cards, Where does it go?

So I'm playing around with the API, I've successfully created a credit card token.
stdClass Object
(
[id] => CARD-5SK44268VP850653PKMZB22Y
[state] => ok
[type] => visa
[number] => xxxxxxxxxxxx0331
[expire_month] => 11
[expire_year] => 2018
[first_name] => Mary
[last_name] => Shopper
[valid_until] => 2017-03-25T00:00:00Z
[create_time] => 2014-03-26T00:20:59Z
[update_time] => 2014-03-26T00:20:59Z
[links] => Array
(
[0] => stdClass Object
(
[href] => https://api.sandbox.paypal.com/v1/vault/credit-card/CARD-5SK44268VP850653PKMZB22Y
[rel] => self
[method] => GET
)
[1] => stdClass Object
(
[href] => https://api.sandbox.paypal.com/v1/vault/credit-card/CARD-5SK44268VP850653PKMZB22Y
[rel] => delete
[method] => DELETE
)
[2] => stdClass Object
(
[href] => https://api.sandbox.paypal.com/v1/vault/credit-card/CARD-5SK44268VP850653PKMZB22Y
[rel] => patch
[method] => PATCH
)
)
)
I'm aware I can update and delete this if I remember the id, but what if I don't remember the ID to reference the card. How can I view all the credit cards I've created. If I forget the ID? It bothers me that I can create them and have them stuck theoretically on Paypal's server forever without a way to delete it through a console or any commands to bring me a list of them? Where exactly do the cards go? Do they disappear into the ether?
Is it possible to get a list of credit cards I've stored?
Any time a credit card is processed on PayPal's platform they save that data in their servers. Of course, they're fully PCI compliant so this isn't an issue for them (or buyers).
That card data is saved and related back to your transaction accordingly so that when you send a request to do a new payment using that card ID it can look it up and process it. So as far as the "where", it's simply PayPal's servers.
To my knowledge you cannot obtain a list of your saved cards.
The Credit Card resource allows you to retrieve all previously saved Credit Cards.
API used for it: '/v1/vault/credit-cards'
There are many possible filters that you could apply to it. For complete list, please refere to developer docs here.
use PayPal\Api\CreditCard;
"params = array(
"sort_by" => "create_time",
"sort_order" => "desc",
"merchant_id" => "Your Merchant ID" // Filtering by MerchantId set during CreateCreditCard.
);"
cards = CreditCard::all($params, $apiContext);
The Credit Card resource allows you to delete saved Credit Cards, You must have its unique creditCardId to perform delete
API used for it: /v1/vault/credit-card/{}
The CreditCard resource allows you to update previously saved Credit Cards. Please note that Credit card id is required for it.
API used for it: PATCH /v1/vault/credit-cards/
use PayPal\Api\CreditCard;
use PayPal\Api\Patch;
You could update a credit card by sending patch requests. Each path object would have a specific detail in the object to be updated.
pathOperation = new Patch();
pathOperation->setOp("replace")
->setPath('/expire_month')
->setValue("12");
To add Another Patch Object, You could set more than one patch while updating a credit card.
"pathOperation2 = new Patch();
pathOperation2->setOp('add')
->setPath('/billing_address')
->setValue(json_decode('{
"line1": "111 First Street",
"city": "Saratoga",
"country_code": "US",
"state": "CA",
"postal_code": "95070"
}'));
pathRequest = new \PayPal\Api\PatchRequest();
pathRequest->addPatch($pathOperation)
->addPatch($pathOperation2);"

PayPal response missing tax

I'm working on an NVP API integration and the entire payment process is working properly. The response I get from PayPal upon completion doesn't provide all the proper information.
Here is the code I am sending PayPal
&PAYMENTREQUEST_0_AMT=44.48
&PAYMENTREQUEST_0_ITEMAMT=40
&PAYMENTREQUEST_0_TAXAMT=4.48
&PAYMENTREQUEST_0_SHPPINGAMT=0
&PAYMENTREQUEST_0_INVNUM=5193f0cca7e70
&PAYMENTREQUEST_0_CURRENCYCODE=USD
&PAYMENTREQUEST_0_DESC=Test payment desc
&L_PAYMENTREQUEST_0_AMT0=40
&L_PAYMENTREQUEST_0_QTY0=1
&L_PAYMENTREQUEST_0_NAME0=Test item
&L_PAYMENTREQUEST_0_NUMBER0=5191cd62462fb
&L_PAYMENTREQUEST_0_DESC0=Test item desc
&L_PAYMENTREQUEST_0_SHPPINGAMT0=0.00
&L_PAYMENTREQUEST_0_TAXAMT0=4.48
&RETURNURL=[REMOVED]
&CANCELURL=[REMOVED]
&BRANDNAME=Some Con 2014
&CUSTOMERSERVICENUMBER=000-000-0000
The order goes through and proper payment is processed, however the information given back is missing the tax information.
[TOKEN] => EC-1KS56755YX305151R
[SUCCESSPAGEREDIRECTREQUESTED] => false
[TIMESTAMP] => 2013-05-15T20:48:42Z
[CORRELATIONID] => 553a6a47ec1
[ACK] => Success
[VERSION] => 98
[BUILD] => 5956203
[INSURANCEOPTIONSELECTED] => false
[SHIPPINGOPTIONISDEFAULT] => false
[PAYMENTINFO_0_TRANSACTIONID] => 1XV29769HY7702037
[PAYMENTINFO_0_TRANSACTIONTYPE] => expresscheckout
[PAYMENTINFO_0_PAYMENTTYPE] => instant
[PAYMENTINFO_0_ORDERTIME] => 2013-05-15T20:48:41Z
[PAYMENTINFO_0_AMT] => 44.48
[PAYMENTINFO_0_FEEAMT] => 1.59
[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_SECUREMERCHANTACCOUNTID] => 3JTQYBPNDRWES
[PAYMENTINFO_0_ERRORCODE] => 0
[PAYMENTINFO_0_ACK] => Success
Why is PAYMENTINFO_0_TAXAMT coming back 0 when it is 4.48?
I'm also having an issue where the email that is sent upon purchase from PayPal is not listing the items purchased and only a general total amount. Notice description is not the item description but the overall order description.
-----------------------------------
Purchase Details
-----------------------------------
Description: Test payment desc
Unit price: $44.48 USD
Qty: 1
Amount: $44.48 USD
Subtotal: $44.48 USD
The tax is not being displayed because it is not getting passed over in your DoExpressCheckoutPayment API call. I checked the logs, and I only show that you passed it over in the SetExpressCheckout API call, but not the DoExpressCheckoutPayment API call. You would need to pass it over in the Do EC call if you are wanting it returned. This is also what is happening with your description. It is not getting passed over in the Do EC call.