в коде JS в /аддонс/payment_paypal/.../payment_form.form.form.form.form.form.form.form.form.form.form.form.form.form.form. PrettyPrint-Override ">
Код: Выделить всё
import paymentForm from '@payment/js/payment_form';
paymentForm.include({
//...
//...
async _prepareInlineForm(providerId, providerCode, paymentOptionId, paymentMethodCode, flow) {
if (providerCode !== 'paypal') {
this._super(...arguments);
return;
}
this._hideInputs();
this._setPaymentFlow('direct');
document.getElementById('o_paypal_button').classList.remove('d-none');
document.getElementById('o_paypal_loading').classList.remove('d-none');
// Check if instantiation of the component is needed.
this.paypalData ??= {}; // Store the component of each instantiated payment method.
const currentPayPalData = this.paypalData[paymentOptionId]
if (this.selectedOptionId && this.selectedOptionId !== paymentOptionId) {
this.paypalData[this.selectedOptionId]['paypalButton'].hide()
}
if (currentPayPalData && this.selectedOptionId !== paymentOptionId) {
const paypalSDKURL = this.paypalData[paymentOptionId]['sdkURL']
const paypalButton = this.paypalData[paymentOptionId]['paypalButton']
await loadJS(paypalSDKURL);
paypalButton.show();
}
else if (!currentPayPalData) {
this.paypalData[paymentOptionId] = {}
const radio = document.querySelector('input[name="o_payment_radio"]:checked');
if (radio) {
this.inlineFormValues = JSON.parse(radio.dataset['paypalInlineFormValues']);
this.paypalColor = radio.dataset['paypalColor']
}
// https://developer.paypal.com/sdk/js/configuration/#link-queryparameters
const { client_id, currency_code } = this.inlineFormValues
const paypalSDKURL = `https://www.paypal.com/sdk/js?client-id=${
client_id}&components=buttons¤cy=${currency_code}&intent=capture`
await loadJS(paypalSDKURL);
const paypalButton = paypal.Buttons({ // https://developer.paypal.com/sdk/js/reference
fundingSource: paypal.FUNDING.PAYPAL,
style: { // https://developer.paypal.com/sdk/js/reference/#link-style
color: this.paypalColor,
label: 'paypal',
disableMaxWidth: true,
borderRadius: 6,
},
createOrder: this._paypalOnClick.bind(this),
onApprove: this._paypalOnApprove.bind(this),
onCancel: this._paypalOnCancel.bind(this),
onError: this._paypalOnError.bind(this),
});
this.paypalData[paymentOptionId]['sdkURL'] = paypalSDKURL;
this.paypalData[paymentOptionId]['paypalButton'] = paypalButton;
paypalButton.render('#o_paypal_button');
}
document.getElementById('o_paypal_loading').classList.add('d-none');
this.selectedOptionId = paymentOptionId;
},
Подробнее здесь: https://stackoverflow.com/questions/796 ... te-the-pay
Мобильная версия