PayPal Express Checkout default Country - paypal

I'm trying to default the billing country to the UK, but no matter what i try it always defaults to the US.
Any ideas?
Note, that we do not require the customer to enter a shipping address so this has been hidden as per the json but have tried setting this to see if it makes a difference with no joy.
I've tried the following:
json_patch_request: [
{
op: 'replace',
path: '/payer/payer_info/billing_address',
value: {
country_code: 'GB',
}
}
],
payer: {
payer_info: {
country_code: 'GB',
billing_address: {
country_code: 'GB',
},
shipping_address: {
country_code: 'GB',
}
}
},
payment: {
transactions: [
{
amount: {
total: 10,
currency: 'GBP'
},
custom: 'x',
},
],
},
experience: {
input_fields: {
no_shipping: 1
},
flow_config: {
landing_page_type: "billing",
},
presentation: {
locale_code: "GB",
},
}

You need to set that in your seller profile:
Log in to your PayPal account
Click Money at the top of the page
Click Manage Currency
Choose the currency to make Primary
Click Make Primary
See https://www.paypal-community.com/t5/About-Payments-Archive/How-to-change-Paypal-default-currency-to-USD/td-p/616528

Related

Showing details of purchase on Checkout pop-up for Paypal

I am a new paypal merchant and am trying to display some information on the checkout pop-up after the client clicks the PAY WITH PAYPAL button. I am using the JavaScript SDK in Sandbox mode
It is a digital purchase, so no shipping is needed -- which works in the code below
The only thing it shows on the Checkout pop-up is the total, "Hi John", Pay With options, and the PAY NOW button.
I want it to show what the client is purchasing, and our company info (name, phone number).
<script src="https://www.paypal.com/sdk/js?client-id=...">
createOrder: function(data, actions) {
// This function sets up the details of the transaction, including the amount and line item details.
var orderDescription = "ITEM YOU PURCHASED" // shows on payment history but not on payment pop-up
return actions.order.create({
intent: "CAPTURE",
purchase_units: [{
description: orderDescription,
amount: {
value: '0.26',
currency_code: "CAD"
}
}],
payee: {
email_address: "email"
},
payee_display_metadata: {
brand_name: "Company Name"
},
application_context: {
shipping_preference: "NO_SHIPPING",
business_name:"My Business Name",
},
note_to_payer: "Contact us at ... for any questions on your order.",
});
},
onApprove: function(data, actions) { .........
Argg..Why is it I always find the answer after I post a question...
I need a item breakdown then I get the down-arrow to expand the cart
changed purchase_units to
purchase_units: [{
amount: {
currency_code: "CAD",
value: "150.00",
breakdown: {
item_total: {
currency_code: "CAD",
value: "150.00"
}
}
},
items: [
{
name: "Tuition",
description: "The best item ever",
sku: "xyz-2654",
unit_amount: {
currency_code: "CAD",
value: "50.00"
},
quantity: "3"
},
]
}],

PayPal Checkout / Smart Buttons - Error with createOrder & empty fields which are optional

With the createOrder function I am passing some of the customer information, mainly to pre-populate the credit / debit card fields.
Something like phone number optional at checkout. With the following code if the order_phone field has a phone number, it works. If it is empty it returns an error and stops. Is there any way around this or let PayPal know it is optional? This happens with other variables too which may be optional for the customer.
createOrder: function(data, actions) {
return actions.order.create({
purchase_units: [{
amount: {
value: $("#grand_total").val(),
currency_code: ("#grand_total").val()
}
}],
"application_context" : {
"shipping_preference":"NO_SHIPPING"
},
payer: {
name: {
given_name: $("#first_name").val(),
surname: $("#last_name").val()
},
email_address: $("#email_address").val(),
phone: {
phone_number: {
national_number: $("#order_phone").val()
}
}
},
});
},
Try something like
createOrder: function(data, actions) {
var myOrder = {
purchase_units: [{
amount: {
value: $("#grand_total").val(),
currency_code: "USD"
}
}],
"application_context" : {
"shipping_preference":"NO_SHIPPING"
},
payer: {
name: {
given_name: $("#first_name").val(),
surname: $("#last_name").val()
},
email_address: $("#email_address").val(),
},
};
var phone = $("#order_phone").val();
if(phone) myOrder.payer.phone = {
phone_number: {
national_number: phone
}
};
return actions.order.create(myOrder);
},

Payment token not in response

==== SOLVED ====
Problem is solved. Adyen wants you to send the whole string as an object. JSON.parse(token). Make sure Google pay is enabled in the Adyen platform.
================
I'm working on transactions with Actions on Google and integration Google Pay. I followed all steps according to the documentation of Actions on Google.
To propose an order I send the following snippet seen below.
Notes:
gateway value is replaced for security reasons.
gatewayMerchantId value is replaced for security reasons.
I'm using a registered gateway.
I have not yet registered as Google partner though the business console so I have no access to the production API.
// Handle order with Google Pay.
conv.ask(new TransactionDecision({
orderOptions: {
requestDeliveryAddress: true,
userInfoOptions: {
userInfoProperties: [
'EMAIL',
],
},
},
paymentParameters: {
googlePaymentOption: {
facilitationSpec: JSON.stringify({
apiVersion: 2,
apiVersionMinor: 0,
environment: 'TEST',
merchantInfo: {
merchantName: 'Example Merchant',
merchantId: '12345678901234567890',
},
allowedPaymentMethods: [
{
type: 'CARD',
parameters: {
allowedAuthMethods: ['PAN_ONLY', 'CRYPTOGRAM_3DS'],
allowedCardNetworks: [
'AMEX', 'DISCOVER', 'JCB', 'MASTERCARD', 'VISA',
],
},
tokenizationSpecification: {
type: 'PAYMENT_GATEWAY',
parameters: {
'gateway': 'my_gateway',
'gatewayMerchantId': 'my_gateway_id',
},
},
},
],
transactionInfo: {
totalPriceStatus: 'FINAL',
totalPrice: prodPriceInclBtwInMicros.toString(),
currencyCode: 'EUR',
},
}),
},
},
presentationOptions: {
actionDisplayName: 'PLACE_ORDER',
},
order: order,
}));
The intent that handles the transaction decision value obtains the following arg value:
const arg = conv.arguments.get('TRANSACTION_DECISION_VALUE');
{
'#type': 'type.googleapis.com/google.actions.transactions.v3.TransactionDecisionValue',
transactionDecision: 'ORDER_ACCEPTED',
order: {
googleOrderId: '02458320178127324049',
merchantOrderId: 'example',
userVisibleOrderId: 'example',
buyerInfo: {
email: 'example#example.com',
firstName: 'example',
lastName: 'example',
displayName: 'example example'
},
createTime: '2020-07-21T10:59:16.624Z',
lastUpdateTime: '2020-07-21T10:59:16.624Z',
transactionMerchant: { name: 'Example Merchant' },
contents: { lineItems: [Array] },
priceAttributes: [ [Object], [Object], [Object] ],
paymentData: { paymentResult: [Object], paymentInfo: [Object] },
purchase: {
status: 'CREATED',
type: 'RETAIL',
userVisibleStatusLabel: 'CREATED'
},
vertical: {
'#type': 'type.googleapis.com/google.actions.orders.v3.verticals.purchase.PurchaseOrderExtension',
status: 'CREATED',
type: 'RETAIL',
userVisibleStatusLabel: 'CREATED'
}
}
}
According to [Adyen][1] I should provide the payment token: 'Get the token from PaymentData response from the Google Pay API.' [Google][2] states that the token will be returned in a response object after the user approves the payment. This is certainly not the case as can be seen in the `arg` object.
By digging deeper into the paymentData, we get the following values:
{
paymentResult: {
googlePaymentData: '{"signature":"MEYCIQDS8Tiu9bprWqamQ24oNx+Wa43Wg6Vi3sP5PArDeOtOEAIhAOBqe4sQvN5tD390qWzDn9DIgwA8gjS8ajynrusOix6O","protocolVersion":"ECv1","signedMessage":"{\\"encryptedMessage\\":\\"Some_tokens_IUHASIDHUSAGFUAHS\\",\\"ephemeralPublicKey\\":\\"SOMEKEYSASD\\\\u003d\\",\\"tag\\":\\"SOMETAG_OIASJDJSOIJ\\\\u003d\\"}"}'
},
paymentInfo: {
paymentMethodDisplayInfo: {
paymentType: 'PAYMENT_CARD',
paymentMethodDisplayName: 'Visa •••• 1234'
},
paymentMethodProvenance: 'PAYMENT_METHOD_PROVENANCE_GOOGLE'
}
}
Still no token returned in the response... This will be necessary for the gateway.
Does anyone know how to resolve this? Or does this have to with the production Transaction API?
Any help is appreciated.
[1]: https://docs.adyen.com/payment-methods/google-pay/api-only
[2]: https://developers.google.com/pay/api/web/reference/response-objects#PaymentData

Remove shipping address option in PayPal Express Checkout

I am using the JS script recommended by PayPal. It's working well, however it is showing a "Ship to" address of the buyers.
I am trying to search the internet and found that https://api.sandbox.paypal.com/v1/payment-experience/web-profiles/ requested with "no_shipping": 1, can do the trick. But for that we need to make a curl request before the payment.create, so that we can pass it returned id in the function.
Is this possible in JS?
Or is there a much better and simpler way to remove it using the following JS?
<script src="https://www.paypalobjects.com/api/checkout.js" data-version-4></script>
<script>
paypal.Button.render({
env: 'sandbox', // Optional: specify 'sandbox' or 'production'
client: {
sandbox: '{{$data['SandboxId']}}',
production: '{{$data['ProductionId']}}'
},
payment: function() {
var amount = document.getElementById("amount").value;
var env = this.props.env;
var client = this.props.client;
return paypal.rest.payment.create(env, client, {
transactions: [
{
amount: {
total: amount,
currency: "USD",
details: {
subtotal: amount,
tax: "0.00",
shipping: "0.00"
}
},
description: "This is payment description.",
item_list: {
items:[
{
quantity:"1",
name:"Orders",
price:amount,
sku:"product12345",
currency:"USD"
}
],
},
}],
});
},
commit: false, // Optional: show a 'Pay Now' button in the checkout flow
onAuthorize: function(data, actions) {
console.log(data);
alert('confirmation here');
// Optional: display a confirmation page here
return actions.payment.execute().then(function() {
alert('Success here');
// Show a success page to the buyer
});
},
}, '#paypal-button');
</script><div id="paypal-button" ></div>
To expand on Bluepnume's answer, here is a complete example:
payment: function(data, actions) {
return actions.payment.create({
payment: {
transactions: [
{
amount: { total: '1.00', currency: 'USD' }
}
]
},
experience: {
input_fields: {
no_shipping: 1
}
}
});
},
You can pass an experience options like so:
paypal.rest.payment.create({
// payment options here
}, {
// experience options here
});
This is how it needs to be done in ngx-paypal version 11
application_context:
{
shipping_preference: "NO_SHIPPING"
}
ngx-paypal: "^11.0.0"

JSON Facebook Payment marked "FRAUD"

In the following JSON, I make a payment in the ChefChili game to purchase virtual currency with my credit card (I am not in the payment testers list). This is showing as FRAUD, whereas it was a genuine payment made by me.
https://graph.facebook.com/382606235186483?access_token=193512574007560|75d4646925b860ec194c69d6cd717ad0
The output of JSON code :
{
id: "382606235186483",
user: {
name: "Abhishek Srivastava",
id: "100001441415841"
},
application: {
name: "ChefChili",
namespace: "chefchili",
id: "193512574007560"
},
actions: [
{
type: "charge",
status: "completed",
currency: "USD",
amount: "1.00",
time_created: "2013-07-26T11:36:49+0000",
time_updated: "2013-07-26T11:36:51+0000"
}
],
refundable_amount: {
currency: "USD",
amount: "1.00"
},
items: [
{
type: "IN_APP_PURCHASE",
product: "https://chefchili.mediaagility.com/product_desc.html",
quantity: 10
}
],
country: "IN",
created_time: "2013-07-26T11:36:49+0000",
fraud_status: "UNKNOWN",
payout_foreign_exchange_rate: 1
}
Also can any one tell me that what is this "fraud_status:UNKNOWN"? and why it is showing "refundable_amount" ?