Set description in paypal API (Client SITE) - javascript

I am trying to set a description for my payment. Code example:
// Make a call to the REST api to create the payment
return actions.payment.create({
payment: {
transactions: [
{
amount: { total: '<?= $amount / 100 ?>', currency: 'EUR' },
description: {'The payment transaction description.'}
}
]
}
});
},
It does not work though. Currently got this example from here: https://developer.paypal.com/docs/api/payments/
Can I set the description on the clientside? Without the description the payment works just fine.

You need to remove the { and } around the description string.

Related

Check if Google Pay is available with JS

There is a system called Engaging Networks where the system provides payment methods like Apple Pay or Google Pay. I would like to show/hide the relevant payment button whether the payment type is available or not.
I know that I can check Apple Pay simply with window.ApplePaySession but I can't see how to check Google Pay availability.
I can see the request has been sent to https://pay.google.com/gp/p/ui/pay, but basically that's it.
Is there any way to check this?
As called out by #esqew, here is an example of how to call isReadyToPay:
function onGooglePayLoaded() {
const client = new google.payments.api.PaymentsClient({
environment: 'TEST',
merchantInfo: {
merchantId: '12345678901234567890',
merchantName: 'Demo Merchant',
},
});
const readyToPayOptions = {
apiVersion: 2,
apiVersionMinor: 0,
allowedPaymentMethods: [
{
type: 'CARD',
parameters: {
allowedAuthMethods: ['PAN_ONLY', 'CRYPTOGRAM_3DS'],
allowedCardNetworks: ['MASTERCARD', 'VISA'],
},
tokenizationSpecification: {
type: 'PAYMENT_GATEWAY',
parameters: {
gateway: 'example',
},
},
},
],
};
client.isReadyToPay(readyToPayOptions).then(result => console.log('Is ready to pay: ', result));
}
<script
async
src="https://pay.google.com/gp/p/js/pay.js"
onload="onGooglePayLoaded()">
</script>

javascript stripe add items with if

I cant seem to get the list of items created dynamically, i want to add additional items, but only if a value is true
stripe.redirectToCheckout({
items: [{
plan: plan,
quantity: quantity,
},
{
plan: 'plan_ddddddd0Hxlu',
quantity: aditionalStorageDays,
}],
successUrl: 'https://example.com/success',
cancelUrl: 'https://example.com/cancel',
customerEmail: '<?php echo $userInfo['email']?>',
}).then(function (result) {
// If `redirectToCheckout` fails due to a browser or network
// error, display the localized error message to your customer
// using `result.error.message`.
});
How do i add the secound item only if aditionalStorage is true?
{
plan: 'plan_ddddddd0Hxlu',
quantity: aditionalStorageDays,
}
Can you explain more...
You mean you want to push the object into array?
Or you want to splace the existing object and then push the new one ?

Paypal - Split payment and send it to different PayPal account

My goal is to get 5% of the amount and send it to Company PayPal account, and the other 95% will send directly to the Paypal of the other user. How can I do it in PayPal Code?
Here is my PayPal code.
paypal.Button.render({
style: {
size: 'responsive',
color: 'black'
},
env: 'sandbox', // 'sandbox' Or 'production',
client: {
sandbox: 'MyClientID',
production: ''
},
locale: 'en_US',
commit: true, // Show a 'Pay Now' button
payment: function(data, actions) {
// Set up the payment here
return actions.payment.create({
payment: {
transactions: [{
amount: { total: '1.00', currency: 'USD' }
}]
}
});
},
onAuthorize: function(data, actions) {
// Execute the payment here
return actions.payment.execute().then(function(payment) {
console.log(payment);
});
}
}, '#paypal-button');
Please help me.. Thank you.
No it's not possible with just a Paypal button. Paypal has its own way to split the money to whichever account you want to set it to and you'll need to use the Payouts API.
Note: It used to be "Adaptive Payments" but they (Paypal) stopped allowing new integrations.
According to the documentation: https://developer.paypal.com/docs/api/payments.payouts-batch/v1/
Use the Payouts API to make PayPal payments to multiple PayPal
accounts in a single API call. The Payouts API is a fast, convenient
way to send commissions, rebates, rewards, and general disbursements.
Please note that you'll need a paypal business account to be elligible for this: https://developer.paypal.com/docs/payouts/integrate/prerequisites/#

Razor Pay checkout form not appearing and giving error as not a function

I am implementing razorPay payment in angular7 project.I am trying to open checkout form by creating a single instance of Razorpay and accessing its function open(). But instead it is throwing error "is not a function". I couldn't find any proper documentation regarding this.
However, If I try to simple create payment using razorpay, it opens up the window but there is no option for user to choose any method and hence it throws error again because directly creating payment will not add up any card(if method is 'card'). So it is necessary to open checkout form.
Here is my function I am using, firstly i create order on server to generate id and then proceed to payment.
buyPlan() {
let postdata = {
amount: 1000,
currency: "INR",
receipt: "1",
notes: {},
payment_capture: true
}
this.common.createOrder(postdata).subscribe(
(result: any) => {
console.log(result)
var razorpay = new this.winRef.nativeWindow.Razorpay({
key: 'dashboard_key_id',
image: 'assets/images/logo-1.png',
});
var data = {
amount: 1000,
currency: "INR",
email: 'abc#example.com',
contact: '9874563210',
notes: {
address: 'Sector 65 Delhi',
},
method: 'card',
order_id: result.data.id,
handler: function (response) {
alert(response.razorpay_payment_id);
}
};
razorpay.open();
}, (err: HttpErrorResponse) => {
}
);
}
For Custom Integration
Remove:
<script src="https://checkout.razorpay.com/v1/checkout.js"></script>
from index.html file
and put:
<script type="text/javascript" src="https://checkout.razorpay.com/v1/razorpay.js"></script>
inside <head></head> tag

Customizing Paypal Checkout Variables

Hi i have been searching around with how I can customize the paypal variable for checkoutJS more specifically with this function here
payment: function (data, actions) {
// Make a call to the REST api to create the payment
return actions.payment.create({
payment: {
transactions: [
{
amount: { total: 'cost', currency: 'PHP' }
}
]
}
});
},
I need to be able to edit the 'cost' based on a text of my div.
i tried doing this ( forgive me if this is stupid ) :
var cost = document.getElementById('cost').InnerText;
payment: function (data, actions) {
// Make a call to the REST api to create the payment
return actions.payment.create({
payment: {
transactions: [
{
amount: { total: cost, currency: 'PHP' }
}
]
}
});
},
Now, when i click the "Buy now" button a popup window appears with a spinner then closes.
I am trying to this in ASP MVC if it is of any relevance.
Help would be very much appreciated!

Categories

Resources