I am using the Paypal PHP REST API SDK, but I can reproduce the problem using curl too. I am able to get a token without a problem. This only occurs when I'm submitting a live payment. I can switch to sandbox and submit an identical payment successfully.
As you can see below this is a very basic payment. I don't see how there could possibly be a problem with the information being submitted.
I have no shortage of debug IDs since this happens every time, but here is the last one I got: 049eee254433f
{
"intent":"sale",
"payer":{
"payment_method":"credit_card",
"funding_instruments":[
{
"credit_card":{
"type":"visa",
"number":"(removed)",
"cvv2":"(removed)",
"expire_month":"1",
"expire_year":"2016",
"first_name":"(removed)",
"last_name":"(removed)"
}
}
]
},
"transactions":[
{
"amount":{
"total":"11.98",
"currency":"USD"
}
}
]
}
The issue, according to the debug ID, is that you are not sending the billing address along with the card information. The option to include/not include the billing address with your request is based upon your merchant account setup. In order to rectify the above error, please provide the billing address in your request.
https://developer.paypal.com/webapps/developer/docs/api/#creditcard-object
Related
I'm trying to implement server side paypal rest api in django rest framework,i have to say paypal's documentation is not helping matters at all,but so far i have been able to successfully pay money from a sandbox buyer account by first getting access token:
def generate_access_token():
url="https://api-m.sandbox.paypal.com/v1/oauth2/token"
headers={
'Content-Type': 'application/json'
}
auth=(settings.PAYPAL_CLIENT_ID,settings.PAYPAL_SECRET_KEY)
data={
"grant_type":"client_credentials"
}
response=requests.post(url,headers=headers,auth=auth,data=data)
token=response.json()['access_token']
return token
Then i create an order for the buyer to pay:
def pay_for_order(token,price,order_id):
url="https://api-m.sandbox.paypal.com/v2/checkout/orders"
headers={
'Content-Type': 'application/json',
'Authorization':f'Bearer {token}'
}
data={
'intent':'CAPTURE',
'application_context':{
'return_url':f'http://127.0.0.1:8000/payment/confirm-payment/1/{token}/',
'cancel_url':f'http://127.0.0.1:8000/payment/confirm-payment/2/{token}/'
},
'purchase_units':[
{
"reference_id":f'{order_id}',
"amount":{
'currency_code':'USD',
'value':f'{price}'
}
}
]
}
response=requests.post(url,headers=headers,data=json.dumps(data))
print(response.json())
response_json=response.json()
return response_json
then the order capture is called in the endpoint in the return url when payment is successful like this:
def final_payment_verification(token,paypal_token):
url=f'https://api.sandbox.paypal.com/v2/checkout/orders/{paypal_token}/capture'
headers={
'Content-Type': 'application/json',
'Authorization':f'Bearer {token}'
}
response=requests.post(url,headers=headers)
print(response.json())
response_json=response.json()
return response_json
but the major issue now is that the seller doesn't get credited my intuition was that generating access token with seller's client id and secret key already stands as identification for whoever the buyer's payment is going to but unfortunately only the buyer get's debited,i checked the whole order api on paypal docs but couldn't find fields that require buyers or recipient info so paypal can pay to them,all solutions online are for client side checkout and paypal docs are not helping matters at all,there are even some read more pages that lead to totally diffrent unrelated content and every resource online mostly use the v1 version other than the latest v2,I would really like to know what i'm doing wrong.
The code is in sandbox mode, so you must be using a sandbox client ID and secret. Are you looking in the seller sandbox account (open a separate tab to log in to www.sandbox.paypal.com with it) that corresponds to the REST APP client ID and secret you are using?
If you still have issues, log the entire capture API response body and include it in your question.
I have got a task to use Google Pay with PayPal in web applications and for that I have gone through numbers of posts over the internet, but not found any well documentation or guide. I have found only google pay codes with payment-gateway mostly and PayPal uses documentation only on PayPal and google blogs, I found that while using it with payment gateway, we don't need any self-created tokenization codes to pass in payment method but when we go with PayPal we must have to use DIRECT token specification method that means we have to create tokenization self for rotation or may be I didn't get it right. My question is that, do we still need public key while working with payment gateway or it belongs to direct method only. I am successfully running payment-gateway integration with test environment but not got any success over PayPal.
While learning about Direct method I understand that we have need to use public key in both payment request and in google pay developer profile but how we can run PayPal in test environment still not found neither any sample nor any success over that.
Below are links I have tried you can use for reference:
https://developers.google.com/pay/api/web/guides/tutorial
https://developers.google.com/pay/api/web/guides/resources/sample-tokens
https://developers.google.com/pay/api/web/reference/request-objects#purchasecontext
https://developers.google.com/pay/api/web/reference/request-objects#gateway
https://developers.google.com/pay/api/web/guides/paymentrequest/tutorial
https://stackoverflow.com/search?page=5&tab=Relevance&q=integrate%20google%20pay
https://developer.paypal.com/docs/archive/checkout/how-to/googlepay-integration/
https://developers.google.com/pay/api/web/guides/tutorial
Here you can see sample of json for payment request in google pay with PayPal.
{
"apiVersion":2,
"apiVersionMinor":0,
"allowedPaymentMethods":[
{
"type":"PAYPAL",
"parameters":{
"purchase_context":{
"payment_intent":"AUTHORIZE",
"purchase_units":[
{
"reference_id":"PUHF",
"description":"Sporting Goods",
"custom_id":"CUST-HighFashions",
"soft_descriptor":"HighFashions",
"payee":{
"merchant_id":"xxxxx"
},
"shipping":{
"method":"United States Postal Service",
"address":{
"name":{
"full_name":"John Doe"
},
"address_line_1":"123 Townsend St",
"address_line_2":"Floor 6",
"admin_area_2":"San Francisco",
"admin_area_1":"CA",
"postal_code":"94107",
"country_code":"US"
}
}
}
]
}
},
"tokenizationSpecification":{
"type":"DIRECT"
}
}
],
"transactionInfo":{
"displayItems":[
{
"label":"Subtotal",
"type":"SUBTOTAL",
"price":"1.00"
},
{
"label":"Tax",
"type":"TAX",
"price":"1.00"
}
],
"countryCode":"US",
"currencyCode":"INR",
"totalPriceStatus":"FINAL",
"totalPrice":"1.00",
"totalPriceLabel":"Total"
},
"merchantInfo":{
"merchantName":"shopgradframes"
},
"callbackIntents":[
"SHIPPING_ADDRESS",
"SHIPPING_OPTION",
"PAYMENT_AUTHORIZATION"
],
"shippingAddressRequired":false,
"shippingAddressParameters":{
"allowedCountryCodes":[
"US"
],
"phoneNumberRequired":true
},
"shippingOptionRequired":false
}
I think we can't use direct method in test environment because this may need merchant details, i have also some doubt over test token given in google blog, you can see that below:
https://developers.google.com/pay/api/web/guides/resources/sample-tokens
I also didn't understand how we can use those test token, do we have to pass it our payment gateway for processing or other stuff.
I am using the orders version 2 APIs of Physical transaction using Google Pay and using Stripe as the payment gateway.
While testing the app using Stripe test publishable I am able to make transactions successfully but when I use the Stripe Live publishable key to generate the chargeable token from Google, the assistant replies with "Something went wrong. Please try again later.". This is happening when I make the conv.ask(new TransactionDecision({})) call.
I get the same response using either of the keys when I disable the Sandbox in the action console simulator.
This response has no error attached with it so I am unable to figure out the cause.
Here is the code-
conv.ask(new TransactionDecision({
orderOptions: {
requestDeliveryAddress: false,
},
paymentOptions: {
googleProvidedOptions: {
prepaidCardDisallowed: false,
supportedCardNetworks: ['VISA', 'AMEX', 'MASTERCARD'],
tokenizationParameters: {
// Tokenization parameter data will be provided by
// a payment processor, like Stripe, Braintree, Vantiv, etc.
parameters: {
'gateway': 'stripe',
'stripe:version': '2019-05-16',
'stripe:publishableKey': process.env.CS_ENV === 'prod' ? process.env.STRIPE_LIVE_PUBLISHABLE_KEY : process.env.STRIPE_TEST_PUBLISHABLE_KEY
},
tokenizationType: 'PAYMENT_GATEWAY',
},
},
},
proposedOrder: order,
}));
Yesterday we were able to create payments and get redirect urls that could be used to approve payments. However today the redirect urls that get returned all result in pages with the message "At this time, we are unable to process your request. Please return to and try another option."
We are also unable to GET previous payments that have not been approved/refunded. Instead we get
{
"name": "INVALID_RESOURCE_ID",
"message": "The requested resource ID was not found",
"information_link": "https://developer.paypal.com/docs/api/#INVALID_RESOURCE_ID",
"debug_id": "ade89339d6e00"
}
Additional debug ids include: d07f86c738cea,5c6da3bb0b6a.
There are allready several posts about this. All you can do is to wait until this issues is fixed by paypal. Fixing the url by yourself wont fix the problem.
I am using PayPal.1.6.0\lib\net45\PayPal.dll
I created a payment with authorize intent and have the successfully authorized authID (Payment.Cart) and the PayPal.APi.Payment.id.
When I try to call the Authorization.Capture(apiContext, Capture) with the authID, I get
{
"name":"INVALID_RESOURCE_ID",
"message":"The requested resource ID was not found",
"information_link":"https://developer.paypal.com/webapps/developer/docs/api/#INVALID_RESOURCE_ID",
"debug_id":"d73f6a0c1b8bc"
}
I tested this using my sandbox account.
Trying the link gets me a 'page not found error'. Any clues?
I realized that i was looking at the wrong 'authorization code'. It is not the ((Payment)executedPayment).cart as posted in my original question but ((Payment)executedPayment).transactions.FirstOrDefault().authorization.id
I was able to use the correct authCode and am able to capture my authorization. executedPayment is the return value from Payment.Execute method.