mirror of
https://github.com/woocommerce/woocommerce-paypal-payments.git
synced 2025-09-12 01:18:39 +08:00
Fix creating wc payment token by checking payment in response
This commit is contained in:
parent
2c4767a55b
commit
946e8172c7
2 changed files with 97 additions and 96 deletions
|
@ -28,6 +28,7 @@ document.addEventListener(
|
|||
init()
|
||||
});
|
||||
|
||||
setTimeout(() => {
|
||||
loadScript({
|
||||
clientId: ppcp_add_payment_method.client_id,
|
||||
merchantId: ppcp_add_payment_method.merchant_id,
|
||||
|
@ -175,6 +176,7 @@ document.addEventListener(
|
|||
});
|
||||
});
|
||||
})
|
||||
}, 1000)
|
||||
}
|
||||
);
|
||||
|
||||
|
|
|
@ -100,8 +100,7 @@ class CreatePaymentToken implements EndpointInterface {
|
|||
if ( is_user_logged_in() && isset( $result->customer->id ) ) {
|
||||
update_user_meta( get_current_user_id(), '_ppcp_target_customer_id', $result->customer->id );
|
||||
|
||||
$payment_method = $data['payment_method'] ?? '';
|
||||
if ( $payment_method === PayPalGateway::ID ) {
|
||||
if ( isset($result->payment_source->paypal) ) {
|
||||
$email = '';
|
||||
if ( isset( $result->payment_source->paypal->email_address ) ) {
|
||||
$email = $result->payment_source->paypal->email_address;
|
||||
|
@ -114,7 +113,7 @@ class CreatePaymentToken implements EndpointInterface {
|
|||
);
|
||||
}
|
||||
|
||||
if ( $payment_method === CreditCardGateway::ID ) {
|
||||
if ( isset($result->payment_source->card) ) {
|
||||
$token = new \WC_Payment_Token_CC();
|
||||
$token->set_token( $result->id );
|
||||
$token->set_user_id( get_current_user_id() );
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue