mirror of
https://github.com/woocommerce/woocommerce-paypal-payments.git
synced 2025-09-05 08:59:14 +08:00
Merge pull request #398 from woocommerce/pcp-400-show-funding-source
Show "Venmo" instead of "PayPal" when using its' button
This commit is contained in:
commit
d5823c1254
13 changed files with 293 additions and 169 deletions
|
@ -14,7 +14,10 @@ const bootstrap = () => {
|
|||
const errorHandler = new ErrorHandler(PayPalCommerceGateway.labels.error.generic);
|
||||
const spinner = new Spinner();
|
||||
const creditCardRenderer = new CreditCardRenderer(PayPalCommerceGateway, errorHandler, spinner);
|
||||
const renderer = new Renderer(creditCardRenderer, PayPalCommerceGateway);
|
||||
const onSmartButtonClick = data => {
|
||||
window.ppcpFundingSource = data.fundingSource;
|
||||
};
|
||||
const renderer = new Renderer(creditCardRenderer, PayPalCommerceGateway, onSmartButtonClick);
|
||||
const messageRenderer = new MessageRenderer(PayPalCommerceGateway.messages);
|
||||
const context = PayPalCommerceGateway.context;
|
||||
if (context === 'mini-cart' || context === 'product') {
|
||||
|
|
|
@ -4,7 +4,8 @@ const onApprove = (context, errorHandler) => {
|
|||
method: 'POST',
|
||||
body: JSON.stringify({
|
||||
nonce: context.config.ajax.approve_order.nonce,
|
||||
order_id:data.orderID
|
||||
order_id:data.orderID,
|
||||
funding_source: window.ppcpFundingSource,
|
||||
})
|
||||
}).then((res)=>{
|
||||
return res.json();
|
||||
|
@ -13,7 +14,7 @@ const onApprove = (context, errorHandler) => {
|
|||
errorHandler.genericError();
|
||||
return actions.restart().catch(err => {
|
||||
errorHandler.genericError();
|
||||
});;
|
||||
});
|
||||
}
|
||||
location.href = context.config.redirect;
|
||||
});
|
||||
|
|
|
@ -7,7 +7,8 @@ const onApprove = (context, errorHandler, spinner) => {
|
|||
method: 'POST',
|
||||
body: JSON.stringify({
|
||||
nonce: context.config.ajax.approve_order.nonce,
|
||||
order_id:data.orderID
|
||||
order_id:data.orderID,
|
||||
funding_source: window.ppcpFundingSource,
|
||||
})
|
||||
}).then((res)=>{
|
||||
return res.json();
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
class Renderer {
|
||||
constructor(creditCardRenderer, defaultConfig) {
|
||||
constructor(creditCardRenderer, defaultConfig, onSmartButtonClick) {
|
||||
this.defaultConfig = defaultConfig;
|
||||
this.creditCardRenderer = creditCardRenderer;
|
||||
this.onSmartButtonClick = onSmartButtonClick;
|
||||
}
|
||||
|
||||
render(wrapper, hostedFieldsWrapper, contextConfig) {
|
||||
|
@ -19,6 +20,7 @@ class Renderer {
|
|||
paypal.Buttons({
|
||||
style,
|
||||
...contextConfig,
|
||||
onClick: this.onSmartButtonClick,
|
||||
}).render(wrapper);
|
||||
}
|
||||
|
||||
|
|
|
@ -184,6 +184,9 @@ class ApproveOrderEndpoint implements EndpointInterface {
|
|||
throw new RuntimeException( $message );
|
||||
}
|
||||
|
||||
$funding_source = $data['funding_source'] ?? null;
|
||||
$this->session_handler->replace_funding_source( $funding_source );
|
||||
|
||||
$this->session_handler->replace_order( $order );
|
||||
wp_send_json_success( $order );
|
||||
return true;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue