[IMP] p_donation_theme: add apple pay btn in product detail screen
This commit is contained in:
parent
c079be8cd2
commit
17ec143a4e
|
|
@ -125,3 +125,9 @@ dmypy.json
|
|||
|
||||
# github action
|
||||
.github/workflows/*yaml
|
||||
|
||||
# config
|
||||
.config/
|
||||
|
||||
# vscode
|
||||
.vscode/
|
||||
|
|
@ -194,7 +194,10 @@ class PaymentPortalExtraFields(PaymentPortal):
|
|||
'tx_id': tx.id
|
||||
}
|
||||
if payment_acquire_id and payment_acquire_id.code == 'applepay' and tx:
|
||||
redirect_url = '/quick/applepay/payment?tx=%s' % (tx.id)
|
||||
if kw.get('is_donation_detail_page'):
|
||||
redirect_url = '/quick/applepay/payment/json?tx=%s' % (tx.id)
|
||||
else:
|
||||
redirect_url = '/quick/applepay/payment?tx=%s' % (tx.id)
|
||||
final_vals.update({
|
||||
'redirect_url': redirect_url
|
||||
})
|
||||
|
|
@ -227,3 +230,32 @@ class PaymentPortalExtraFields(PaymentPortal):
|
|||
{'check_out_id': kw.get('check_out_id'), 'return_url': kw.get('applepay_return')})
|
||||
else:
|
||||
return request.redirect('/')
|
||||
|
||||
@http.route('/quick/applepay/payment/json', type='json', auth='public', website=True)
|
||||
def apple_pay_payment_method_json(self, **kwargs):
|
||||
tx = kwargs.get('tx')
|
||||
payment_sudo = request.env['payment.transaction'].sudo()
|
||||
tx = payment_sudo.search([('id', '=', int(tx))], limit=1)
|
||||
if tx:
|
||||
kw = tx._get_processing_values()
|
||||
kw = tx._get_specific_rendering_values(kw)
|
||||
|
||||
acquirer = request.env['payment.provider'].sudo().search([('code', '=', 'applepay')], limit=1)
|
||||
|
||||
kw['currency'] = 'SAR'
|
||||
_logger.info("Post Values From Apple Payment = %s" % (kw))
|
||||
|
||||
if acquirer.state == 'test':
|
||||
content = request.env['ir.ui.view'].sudo()._render_template(
|
||||
'payment_applepay.payment_applepay_card',
|
||||
{'check_out_id': kw.get('check_out_id'), 'return_url': kw.get('applepay_return')}
|
||||
)
|
||||
return {'content': content}
|
||||
else:
|
||||
content = request.env['ir.ui.view'].sudo()._render_template(
|
||||
'payment_applepay.payment_applepay_card_live',
|
||||
{'check_out_id': kw.get('check_out_id'), 'return_url': kw.get('applepay_return')}
|
||||
)
|
||||
return {'content': content}
|
||||
else:
|
||||
return request.redirect('/')
|
||||
|
|
|
|||
|
|
@ -33,6 +33,37 @@ odoo.define('p_donation_theme.product-gift-card', function (require) {
|
|||
|
||||
},
|
||||
|
||||
async start() {
|
||||
await this._super(...arguments);
|
||||
const $parent = this.$el.find('.js_product');
|
||||
const product_id = this._getProductId($parent);
|
||||
if (product_id) {
|
||||
const data = await this._rpc({
|
||||
route: '/quickpay/hyperpay/payment/create',
|
||||
params: {
|
||||
'acquire_id': 20,
|
||||
'product_id': product_id,
|
||||
'currency_id': 148,
|
||||
'mobile': '',
|
||||
'amount': 100,
|
||||
'is_donation_detail_page': true
|
||||
}
|
||||
});
|
||||
if (data.redirect_url) {
|
||||
const apple_pay_form = await this._rpc({
|
||||
route: data.redirect_url,
|
||||
params: {
|
||||
'tx': data.tx_id
|
||||
}
|
||||
});
|
||||
if (apple_pay_form.content) {
|
||||
const $applePayEl = $(apple_pay_form.content);
|
||||
$applePayEl.prependTo($('.temp-donate-now').parent());
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
_submitForm() {
|
||||
const params = this.rootProduct;
|
||||
const $product = $('#product_detail');
|
||||
|
|
|
|||
Loading…
Reference in New Issue