PayPal Billing Agreement - No approval_url or redirect_url after creation - paypal

I am trying to set up Billing Agreements using PayPal REST API with paypal-rest-api-sdk for Java on PayPal Sandbox. So, far I've been able to create a billing plan and pass it's id to create a Billing Agreement. However, the response that I get after creating a Billing Agreement does not have approval_url and redirect_url. The following is my request
{
"name": "MYOP Recurring Contribution Agreement",
"description": "Agreement for MYOP Recurring Contributions",
"start_date": "2014-12-13T06:26:32Z",
"payer": {
"payment_method": "credit_card",
"funding_instruments": [
{
"credit_card": {
"number": "XXXXXXXXXXXX",
"type": "visa",
"expire_month": 1,
"expire_year": 2015,
"cvv2": 874,
"first_name": "Joe",
"last_name": "Young",
"billing_address": {
"line1": "52 N Main ST",
"city": "Johnstown",
"country_code": "US",
"postal_code": "43210",
"state": "OH"
}
}
}
]
},
"plan": {
"id": "P-85A16162MC374104FU7KAYMQ"
}
}
As a response to my create Billing Agreement request, I receive only the following:
{
"id": "I-77GK9WNNV04U",
"links": [
{
"href": "https://api.sandbox.paypal.com/v1/payments/billing-agreements/I-77GK9WNNV04U",
"rel": "self",
"method": "GET"
}
]
}
When I fetch the created Billing Agreement with a GET request on the agreement id, I receive information about the agreement that has a 'links' array that does not contain approval_url or redirect_url.
I am unable to proceed to send the payer to an approval url to then execute the agreement. Help please.

You are using ("payment_method":"credit_card") Change the ("Payment_method":"PAYPAL")
'{
"name": "T-Shirt of the Month Club Plan",
"description": "Template creation.",
"start_date": "2016-03-31T00:37:04Z",
"plan": {
"id":"'.$plan_id.'"
},
"payer": {
"payment_method": "PAYPAL"
},
"shipping_address": {
"line1": "111 First Street",
"city": "Saratoga",
"state": "CA",
"postal_code": "95070",
"country_code": "US"
}
}';
Thanks

The approval and the redirect url is only applicable when you make the PayPal Payments so that the buyers can login to their PayPal account and approve the transaction .
Since you are making the billing agreement on credit card , the recurring profile will be created right away and need not go thru any redirect url .

Related

Paypal API/ agreement page / hide shipping address block

I have a digital product and therefore want to hide the shipping block.
I use Paypal API CURL Create agreement
My CURL post data:
{
"name": "user#user.com Agreement",
"description": "Essential 1 Plan - 19$ trial 7 days - 1$",
"start_date": "2021-11-11T00:52:01Z",
"payer": {
"payment_method": "paypal"
},
"plan": {
"id": "P-XXXXXXXXXXXXXXXXXXXXXXXX"
},
"override_merchant_preferences": {
"setup_fee": {
"value": 0,
"currency": "USD"
},
"return_url": "http://domain.local/membership/checkout/success",
"cancel_url": "http://domain.local/membership/checkout/cancel",
"auto_bill_amount": "YES",
"initial_fail_amount_action": "CONTINUE",
"max_fail_attempts": 2
}
}
I read that I need to set the
no_shipping => 1
parameter, but I don't know where.
Please help find a solution.

How to create a Subscription payment using Paypal client-side rest api?

The Client-side REST integration documentaion describes about creating a express checkout for one or more items.
How can i use the same for creating a subscription or Recurring payment? How should the following be modified?
payment: function(data, actions) {
return actions.payment.create({
transactions: [
{
amount: { total: '1.00', currency: 'USD' }
}
]
});
},
I found a similar Rest api for Node. Not sure how it would be on JS.
First you need to create a billing plan:
billing_plan_attributes = {
"name": PLAN_NAME_HERE,
"description": PLAN_DESCRIPTION,
"merchant_preferences": {
"auto_bill_amount": "yes", # yes if you want auto bill
"cancel_url": "http://www.cancel.com", # redirect uri if user cancels payment
"initial_fail_amount_action": "continue",
"max_fail_attempts": "1",
"return_url": RETURN_URL,
"setup_fee": {
"currency": CURRENCY,
"value": VALUE # how much do you want to charge
}
},
"payment_definitions": [
{
"amount": {
"currency": request.form['currency'],
"value": request.form['amount']
},
"cycles": CYCLES, # how much time this subscription will charge user
"frequency": FREQ, # month, day
"frequency_interval": INTERVAL, # per month or per three month or so on
"name": NAME,
"type": TYPE
}
],
"type": TYPE
}
billing_plan = BillingPlan(billing_plan_attributes)
if billing_plan.create():
print("success")
The attributes used have literal meaning here. Now since you have created a billing plan you need to give users some interface so that they can subscribe with it. Below is a sample code for this:
billing_agreement = BillingAgreement({
"name": "Organization plan name",
"description": "Agreement for " + request.args.get('name', ''),
"start_date": (datetime.now() + timedelta(hours=1)).strftime('%Y-%m-%dT%H:%M:%SZ'),
"plan": {
"id": request.args.get('id', '')
},
"payer": {
"payment_method": "paypal"
},
"shipping_address": {
"line1": "StayBr111idge Suites",
"line2": "Cro12ok Street",
"city": "San Jose",
"state": "CA",
"postal_code": "95112",
"country_code": "US"
}
})
if billing_agreement.create():
for link in billing_agreement.links:
if link.rel == "approval_url":
approval_url = link.href
In the last line you get the approval link which can be given to user.
Next you have to setup an endpoint which will be the callback url if user approves the payment.
billing_agreement_response = BillingAgreement.execute(payment_token)
payment_token is sent by paypal to your callback url.

PayPal hide order total

I am using PayPal's REST API to implement paying via PayPal into my website. When I send an approval request to PayPal it always shows the order total. I really don't want to show this. At the point in which we are asking for approval the user won't even know what their total order amount will be. Is there anyway to hide the order total on the PayPal page?
Are you sending line items in your API request? For example:
"item_list": {
"items": [{
"name": "Test",
"sku": "18",
"price": "7.47",
"currency": "USD",
"quantity": "1"
}
]
}
If you send the items array, the price will be displayed in PayPal's payment page.
However, you can just send a total amount, and it won't appear during buyer approval, for example:
{
"intent": "sale",
"redirect_urls": {
"return_url": "http://URL.com/restapi_test/_payments_execute-an-approved-paypal-payment.html",
"cancel_url": "http://URL.com/restapi_test/_payments_create-a-payment-paypal.html"
},
"payer": {
"payment_method": "paypal"
},
"transactions": [{
"amount": {
"total": "7.47",
"currency": "USD"
},
"description": "This is the payment transaction description."
}]
}

Visa checkout Integration

I am trying to integrate visa checkout on a site which uses paypal payment processing.
Earlier we integrated Google Wallet on our site and google wallet returned a discover card for any card selected from the google wallet and we were just passing the card details to paypal for furthur payment processing. The card response from google wallet looked something like this
"aud": "01409448849434218847",
"iat": 1424749827,
"exp": 1424753427
},
"pan": "6011988571714740",
"cvn": "827"
where pan is the discover card number and cvn is the cvv number.
But in case of visa checkout, the cvv number is not returned. A sample payment data response from visa checkout looks like this
{
"paymentRequest": {
"currencyCode": "USD",
"total": "10"
},
"userData": {
"userFirstName": "XYZ",
"userLastName": "XYZ",
"userName": "XYZ#gmail.com",
"userEmail": "XYZ#gmail.com",
"encUserId": "kFilkXPMqx9P2sxVBwZpwHZ3ZppIJSASFXOlMt/u/SU="
},
"creationTimeStamp": 1427169634910,
"paymentInstrument": {
"id": "Rjgzv/9FVVM09JiLGNHzqZlnc+h0vTA8E/NPESuZvOU=",
"lastFourDigits": "xxxx",
"binSixDigits": "xxxxxx",
"paymentType": {
"cardBrand": "VISA",
"cardType": "PREPAID"
},
"billingAddress": {
"personName": "XYZ ABC",
"line1": "131 Dartmouth St",
"city": "Boston",
"stateProvinceCode": "MA",
"postalCode": "02116",
"countryCode": "US",
"phone": "9123456789"
},
"verificationStatus": "VERIFIED",
"expired": false,
"cardArts": {
"cardArt": [
{
"baseImageFileName": "https://sandbox.secure.checkout.visa.com/VmeCardArts/uWOvgFoQISxPh_MWE7gO8xJHi_Kwti3ZgptHQ1LkSR4.png",
"height": 50,
"width": 77
}
]
},
"issuerBid": "14",
"nameOnCard": "XYZ ABC",
"expirationDate": {
"month": "01",
"year": "2018"
}
},
"shippingAddress": {
"id": "vn9XOKl/FOLHzEOrs2KoF3qA2VoFoQoaz6phbibsCVE=",
"verificationStatus": "VERIFIED",
"personName": "XYZ ABC",
"line1": "131 Dartmouth St",
"city": "Boston",
"stateProvinceCode": "MA",
"postalCode": "02116",
"countryCode": "US",
"phone": "9123456789",
"default": false
},
"riskData": {
"advice": "LOW",
"score": 0,
"avsResponseCode": "Y",
"cvvResponseCode": "M"
},
"partialShippingAddress": {
"countryCode": "US",
"postalCode": "02116"
}
}
Here we don't get the actual CVV number.
Any idea, how we can proceed with the paypal payment processing without the cvv number. (The card number comes as account number, but is not present in this response).
For security reasons, you will never receive the CVV number per Visa. You will instead receive a letter value indicating a match or not. They say that is enough to process the payment.

Paypal REST AVS/CV2 codes

I'm using PayPal REST API via rest-api-sdk-java and would like to ask whether it is possible to get AVS/CVV match results in the response (or error object).
I did couple of tests (with sandbox and negative testing turned on) according to https://developer.paypal.com/docs/classic/lifecycle/sb_error-conditions/ (parts "Testing AVS errors" and "Testing CVV code"):
Payment request with billing address street "123 AVS_A Street" results in INTERNAL_SERVICE_ERROR:
{
"name": "INTERNAL_SERVICE_ERROR",
"debug_id": "baf56174e98c8",
"message": "An internal service error has occurred",
"information_link": "https://developer.paypal.com/webapps/developer/docs/api/#INTERNAL_SERVICE_ERROR"
}
The same payment request with billing address street "123 AVS_M Street" results in successful sale.
Is INTERNAL_SERVICE_ERROR expected error in such scenario (AVS_A) ? Is there any way how to get "raw AVS code" instead of INTERNAL_SERVICE_ERROR or CREDIT_CARD_REJECTED?
My request payload:
{
"intent": "sale",
"payer": {
"payment_method": "credit_card",
"funding_instruments": [
{
"credit_card": {
"number": "4446283280247004",
"type": "visa",
"expire_month": 11,
"expire_year": 2018,
"cvv2": "888",
"first_name": "Susan",
"last_name": "Wagner",
"billing_address": {
"line1": "123 AVS_A Street",
"line2": "Billing Address Line 2",
"city": "London",
"country_code": "GB",
"postal_code": "W1T 2BU",
"state": "",
"phone": "12345"
}
}
}
]
},
"transactions": [
{
"amount": {
"currency": "GBP",
"total": "3.55",
"details": {
"shipping": "0.00",
"subtotal": "3.55",
"tax": "0.00"
}
},
"description": "T-Shirt XYZ"
}
]
}
And one more question: Is it possible to use advanced Fraud Management Filters on Sandbox environment? I'm using Pro test account but still can't use the filters (nothing happens when I click "upgrade now" button):
https://www.sandbox.paypal.com/uk/cgi-bin/webscr?cmd=_rc-manage
looking at the debug id, the test did work - sort of -
Internal Sandbox API Error is 10555 - Filter Decline
--> https://developer.paypal.com/webapps/developer/docs/classic/api/errorcodes/
The transaction was declined because of a merchant risk filter for AVS. Specifically, the merchant has set the filter to decline transactions when the AVS returns a partial match.
So you've likely enabled the AVS fraud management filter on the sandbox account.
Obviously, there should be a proper error message and not just an internal service error, but it looks like the error hasn't been mapped yet.
Will follow up with the PP Devs to report & fix it ;)
As for AVS / CVV response within REST - there doesn't seem to be a way to retrieve the AVS/CVV response of the issuing bank just yet.