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

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);"

Related

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?

Bug with negative amounts in PayPal API

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

How do I populate Stripe's description field on subscription charge?

I can populate Business::Stripe's description field for one off charges with the below code :
use Business::Stripe; # Version 0.4
# Create Customer
my $customer = $stripe->api('post', 'customers',
card => $stripeToken,
description => $username,
);
# Charge
my $charge = $stripe->api('post', 'charges',
customer => $customer,
currency => $currency,
description => 'my description here no probs',
amount => $amount,
);
But when I create a customer a customer and assign them to a subscription plan I can't see how to populate the description of the charge made each billing period.
# Create Customer and subscribe to a plan
my $customer = $stripe->api('post', 'customers',
card => $stripeToken,
description => 'description here is for the customer not the monthly charge',
plan => $plan
);
I want to be able to add a description to the charge that happens each billing period.
The API doesn't seem to show a way but the field is editable via the strie dashboard.
Stripe is thinking about auto-populating the charge description on invoices, but that's not a feature that exists yet. In the meantime, once the invoice.payment_succeeded event occurs, you can get the charge ID from that event data. Then you can update the charge's description via the API:
https://stripe.com/docs/api#update_charge
Hope that helps,
Larry
PS I work on Support at Stripe.

Paypal API GetVerifiedStatus return User is not allowed to perform this action

Hy,
I would like to use GetVerifiedStatus of Paypal API.
So I have create my application and I have an application ID.
In sandbox, all is ok, the service return the status of my customer.
But when I make a live call I have this error :
"User is not allowed to perform this action"
Do you have a solution?
Thanks!
Request :
Array
(
[emailAddress] => myCustomer#email.com
[matchCriteria] => NONE
)
Response :
stdClass Object
(
[responseEnvelope] => stdClass Object
(
[timestamp] => 2013-10-29T06:47:26.456-07:00
[ack] => Failure
[correlationId] => 21820ac9a046c
[build] => 7784095
)
[error] => Array
(
[0] => stdClass Object
(
[errorId] => 550001
[domain] => PLATFORM
[subdomain] => Application
[severity] => Error
[category] => Application
[message] => User is not allowed to perform this action
)
)
)
(Paypal GetVerifiedStatus with "User is not allowed to perform this action" : This is not the same problem because he update the error with "Cannot determine PayPal Account status")
In order to perform the GetVerifiedStatus call in a live environment, you need to pass also firstName and lastName in the arguments, and they need to be consistent with those of the PayPal account for the email address you are checking. You also need to set matchCriteria to 'NAME'. So, your request would look like:
Array (
[emailAddress] => myCustomer#email.com
[firstName] => myCustomerFirstName
[lastName] => myCustomerLastName
[matchCriteria] => NAME
)
Try updating the merchant PayPal account to a business account and verify it.