Я пытаюсь реализовать Paypal, используя валюту MYR.Тем не менее, я получил сообщение об ошибке, которая не одобрила карту пользователя.
Сообщение было «Извините, но ваша Visa x-xxxx была отклонена. Вы можете завершить покупку с выбранным способом оплаты или выбрать другой способ оплаты».
Кто-нибудь сталкивался /есть решение этой проблемы?
<script src="https://www.paypalobjects.com/api/checkout.js"></script>
<script>
// Render the PayPal button
paypal.Button.render({
// Set your environment
//env: 'sandbox', // sandbox | production
env: 'production', // sandbox | production
// Specify the style of the button
style: {
layout: 'vertical', // horizontal | vertical
size: 'medium', // medium | large | responsive
shape: 'rect', // pill | rect
color: 'gold' // gold | blue | silver | white | black
},
// Specify allowed and disallowed funding sources
//
// Options:
// - paypal.FUNDING.CARD
// - paypal.FUNDING.CREDIT
// - paypal.FUNDING.ELV
funding: {
allowed: [
//paypal.FUNDING.CARD,
//paypal.FUNDING.CREDIT
],
disallowed: []
},
// Enable Pay Now checkout flow (optional)
commit: true,
// PayPal Client IDs - replace with your own
// Create a PayPal app: https://developer.paypal.com/developer/applications/create
client: {
//sandbox: 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx',
production: 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx',
},
payment: function (data, actions) {
return actions.payment.create({
payment: {
transactions: [
{
amount: {
total: parseFloat(document.querySelector('.custom-modal-data').getAttribute("data-value")),
currency: 'MYR'
//currency: 'USD'
}
}
]
}
});
},
/*onAuthorize: function (data, actions) {
return actions.payment.execute()
.then(function () {
window.alert('Payment Complete!');
});
},*/
onAuthorize: function (data, actions) {
return actions.payment.execute()
.then(function () {
return actions.payment.get().then(function(data) {
//console.log(data);
//console.log(data.transactions);
//console.log(data.transactions[0].related_resources[0].sale.id);
if(data.state == "approved"){
var data = data;
var transaction = data.transactions[0];
var box = $('body').find(`[data-chosen="1"]`);
var package = box.find('.top-up-btn').attr('data-package');
var action = 'userTopupPaypal';
var collection = {
action:action,
data:data,
transaction:transaction,
package:package,
}
//console.log(collection);
var modal = $('#modalTopup');
modal.find(".custom-modal-header-title").text("Processing...");
$.ajax({
type: "POST",
url: "submits/submit-topup.php",
data:collection,
dataType:'JSON',
success: function(result){
console.log(result);
hideModalTopup();
var status = result.status;
if(status == 'Success'){
Swal.fire(
'Success!',
'Your have successfully topup.',
'success'
);
} else {
Swal.fire(
'Oppps...',
'Something went wrong.',
'error'
);
}
}
});
}
});
});
}
}, '#paypal-button-container');