I am working in my Ionic App and I have added the PayPal native plugin in my app but when I have added the 'INR' currency in PayPal code it is not opening in the real device and when I changed the currency to 'USD' it is opening.
This is my checkout.ts:
makepaymentp()
{
//console.log("Payment");
this.PayPalMobile.init({
PayPalEnvironmentProduction: 'YOUR_PRODUCTION_CLIENT_ID',
PayPalEnvironmentSandbox: '-----------------------------',
}).then(() => {
// Environments: PayPalEnvironmentNoNetwork, PayPalEnvironmentSandbox, PayPalEnvironmentProduction
this.PayPalMobile.prepareToRender('PayPalEnvironmentSandbox', new PayPalConfiguration({
// Only needed if you get an "Internal Service Error" after PayPal login!
//payPalShippingAddressOption: 2 // PayPalShippingAddressOptionPayPal
})).then(() => {
let payment = new PayPalPayment(this.totalpricec, 'INR', 'Description', 'sale');
this.PayPalMobile.renderSinglePaymentUI(payment).then(() => {
// Successfully paid
// Example sandbox response
//
// {
// "client": {
// "environment": "sandbox",
// "product_name": "PayPal iOS SDK",
// "paypal_sdk_version": "2.16.0",
// "platform": "iOS"
// },
// "response_type": "payment",
// "response": {
// "id": "PAY-1AB23456CD789012EF34GHIJ",
// "state": "approved",
// "create_time": "2016-10-03T13:33:33Z",
// "intent": "sale"
// }
// }
}, () => {
// Error or render dialog closed without being successful
console.log("Error or render dialog closed without being successful");
});
}, () => {
// Error in configuration
console.log("Error in configuration");
});
}, () => {
// Error in initialization, maybe PayPal isn't supported or something else
console.log("Error in initialization, maybe PayPal isn't supported or something");
});
}
I am running the app in my device and it is not running for the 'INR' and it is running for the 'USD'.
Can anyone help me how to run the code for 'INR' in PayPal in Ionic App.
Any help is much appreciated.
{
"scope": "https://uri.paypal.com/services/subscriptions https://api.paypal.com/v1/payments/.* https://api.paypal.com/v1/vault/credit-card https://uri.paypal.com/services/applications/webhooks openid https://uri.paypal.com/payments/payouts https://api.paypal.com/v1/vault/credit-card/.*",
"nonce": "2017-06-08T18:30:28ZCl54Q_OlDqP6-4D03sDT8wRiHjKrYlb5EH7Di0gRrds",
"access_token": "Access-Token",
"token_type": "Bearer",
"app_id": "APP-80W284485P519543T",
"expires_in": 32398
}
Related
I'm using paypal to receive payments, but I would like to pass a form of installment to the user, but depending on the values, I wanted this to be variable, I didn't find anything in the documentation about it, is it possible?
this.paypalConfig = {
currency: 'BRL',
createOrder: function (data, actions) {
return actions.order.create({
intent: "CAPTURE",
purchase_units: [{
"amount":
{
"value": self.amount,
"currency_code": "BRL",
"description": self.name,
},
}]
});
},
onApprove: function (data, actions) {
return actions.order.capture().then(function (details) {
},
onCancel: function (data) {
// Show a cancel page, or return to cart
console.log(data);
},
onError: function (err) {
// Show an error page here, when an error occurs
console.log(err);
},
}
For BR payments in BRL, installments can be configured at the live PayPal Business account level
(and if you are testing in sandbox with a BR sandbox business account you can also log into Sandbox here to enable installments)
More information on PayPal.com (Portuguese)
I have an ecommerce platform that has multiple sellers selling products and I want to use PayPal checkout v2 Javascript to send a payment to multiple merchants.
Using v2 JavaScript API:
https://www.paypal.com/sdk/js?client-id=CLIENT_ID&disable-funding=credit,card
paypal.Buttons({
onInit: function(data, actions) {
},
createOrder: function(data, actions) {
return actions.order.create({
"purchase_units": [
{
"reference_id": "1",
"amount": {
"currency_code": "AUD",
"value": "20.00",
"breakdown": {
"item_total": {
"currency_code": "AUD",
"value": "20.00"
}
}
},
"payee": {
"email_address": "payee1#business.example.com"
}
},
{
"reference_id": "2",
"amount": {
"currency_code": "AUD",
"value": "10.00",
"breakdown": {
"item_total": {
"currency_code": "AUD",
"value": "10.00"
}
}
},
"payee": {
"email_address": "payee2#business.example.com"
}
}
]
});
},
onApprove: function(data, actions) {
return actions.order.capture().then(function(details) {
alert('Transaction completed by ' + details.payer.name.given_name);
});
},
onError: function (err) {
alert(err.message);
}
}).render('#paypal-button');
I can login as a payer and see total $30, when I click Pay Now it says error "Order can not be captured". If I remove the second purchase unit object (payee 2) the transaction is approved.
I read on PayPal forums and api documentations and see mostly deprecated methods. How do I send a payment to multiple merchants now adays?
There is no mechanism for approving multiple v2/checkout/orders purchase_units with the JS checkout.
The deprecated methods should also not be used
How do I send a payment to multiple merchants now adays?
You don't -- not simultaneously, anyway. Each is its own separate checkout/approval event.
You have to create app as platform in your sandbox or live account
its best user experience to use js integration with multi seller checkout
You have pass merchantids on url and in js section as below
if multiple seller use this
multiple seller
<script
src="https://www.paypal.com/sdk/js?client-id=client_id&intent=capture&disable-funding=credit&merchant-id=*¤cy=USD"
data-partner-attribution-id="bn_code"
data-merchant-id="merchant_id1,merchant_id2"
>
</script>
single seller
<script
src="https://www.paypal.com/sdk/js?client-id=client_id&intent=capture&disable-funding=credit&merchant-id=merchant_id1¤cy=USD"
data-partner-attribution-id="bn_code"
data-merchant-id="merchant_id1"
>
</script>
Then you have to use js sdk integration with div as below
paypal.Buttons({
style : {
color: 'gold',
shape: 'pill',
label: 'pay',
},
createOrder: function (data, actions) {
return actions.order.create(data.json);
},
onApprove: function (data, actions) {
return actions.order.capture().then(function (details) {
//redirect to your server
window.location.replace(base_url+'paypal/create_order/'+details.id)
})
},
onCancel: function (data) {
console.log(data);
},
onError: function (err) {
// For example, redirect to a specific error page
console.log(err);
}
}).render('#paypal-payment-button');
For how to create order please check the documentation.
I want to log all failed and success response of payment. Handler option return payment id in the success case and nothing in the failure case. How to log failure payment id?
var options = {
"key": "API_KEY",
"amount": "2000", // 2000 paise = INR 20
"name": "Product",
"callback_url":"http://myweb.com/process.php",
"description": "Purchase Description",
"image": "https://myweb.com/images/image.png",
"handler": function (response){
alert(response.razorpay_payment_id);
},
"prefill": {
"name": "Harshil Mathur",
"email": "harshil#razorpay.com"
},
"notes": {
"address": "Hello World"
},
"theme": {
"color": "#F37254"
}
};
var rzp1 = new Razorpay(options);
document.getElementById('rzp-button1').onclick = function(e){
rzp1.open();
e.preventDefault();
}
There is a concept called webhook in razorpay
You can get every response to that hook and you can capture anything from there
Please goahead Razorpay webhook
I have implemented paypal integration in my mobile app. I am using Rest APIs. It was working fine before a month but suddenly stops working with the following error message :
Things don't appear to be working at the moment.Please try again later.
I am getting this error when I try to login in with my sandbox credentials.
Here is my JSON :
{
"intent":"sale",
"redirect_urls":{
"return_url":"https://www.google.com/",
"cancel_url":"https://www.google.com/"
},
"payer":{
"payment_method":"paypal",
"payer_info":null
},
"transactions":[
{
"amount":{
"total":"45.9",
"currency":"AUD",
"details":{
"subtotal":"45.9",
"tax":"0",
"shipping":"0"
}
},
"item_list":{
"items":[
{
"quantity":"1",
"name":"Stainless Braided Hose Black",
"price":"45.9",
"currency":"AUD",
"description":"Description not available",
"tax":"0"
}
],
"shipping_address":{
"recipient_name":"Harry p",
"line1":"104, pavan",
"line2":"Shahibaug",
"city":"Ahm",
"country_code":"AU",
"postal_code":"124536",
"phone":"252253656",
"state":"Guj"
}
},
"description":null
}
]
}
What permission is needed for udp in a chrome app?
I get the error:
Unchecked runtime.lastError while running sockets.udp.bind: App does not have permission
but I can't find the permission needed.
My manifest.json file looks like this:
{
"name": "XX",
"description": "XX",
"version": "0.0.1",
"manifest_version": 2,
"app": {
"background": {
"scripts": ["main.js"]
}
},
"icons": {
"16": "icon-16.png",
"128": "icon-128.png"
},
"sockets": {
"udp": {
"send": "*"
}
},
"permissions": [
"fullscreen", "alwaysOnTopWindows", "videoCapture", "storage", "browser"
]
}
you need to ask for the bind permission
"udp": {
"send": ["*"],
"bind": ["*"]
}
Using UDP
Chrome Apps can make connections to any service that supports UDP.
Sending data
Here's a sample showing how to send data (sockets.udp.send) over the network using UDP:
// Create the Socket
chrome.sockets.udp.create({}, function(socketInfo) {
// The socket is created, now we can send some data
var socketId = socketInfo.socketId;
chrome.sockets.udp.send(socketId, arrayBuffer,
'127.0.0.1', 1337, function(sendInfo) {
console.log("sent " + sendInfo.bytesSent);
});
});
Receiving data
This example is very similar to the 'Sending data' example, except we setup an event handler for receiving data.
var socketId;
// Handle the "onReceive" event.
var onReceive = function(info) {
if (info.socketId !== socketId)
return;
console.log(info.data);
};
// Create the Socket
chrome.sockets.udp.create({}, function(socketInfo) {
socketId = socketInfo.socketId;
// Setup event handler and bind socket.
chrome.sockets.udp.onReceive.addListener(onReceive);
chrome.sockets.udp.bind(socketId,
"0.0.0.0", 0, function(result) {
if (result < 0) {
console.log("Error binding socket.");
return;
}
chrome.sockets.udp.send(socketId, arrayBuffer,
'127.0.0.1', 1337, function(sendInfo) {
console.log("sent " + sendInfo.bytesSent);
});
});
});
for more info: look here