mirror of
https://github.com/woocommerce/woocommerce-paypal-payments.git
synced 2025-09-05 08:59:14 +08:00
Add PayPal order id into WC order meta
This commit is contained in:
parent
150d29c0b4
commit
53de52e2d3
9 changed files with 40 additions and 1 deletions
|
@ -145,8 +145,15 @@ class Orders {
|
||||||
|
|
||||||
$status_code = (int) wp_remote_retrieve_response_code( $response );
|
$status_code = (int) wp_remote_retrieve_response_code( $response );
|
||||||
if ( $status_code !== 200 ) {
|
if ( $status_code !== 200 ) {
|
||||||
|
$body = json_decode( $response['body'] );
|
||||||
|
|
||||||
|
$message = $body->details[0]->description ?? '';
|
||||||
|
if ( $message ) {
|
||||||
|
throw new RuntimeException( $message );
|
||||||
|
}
|
||||||
|
|
||||||
throw new PayPalApiException(
|
throw new PayPalApiException(
|
||||||
json_decode( $response['body'] ),
|
$body,
|
||||||
$status_code
|
$status_code
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,6 +13,7 @@ use WC_Payment_Gateway;
|
||||||
use WooCommerce\PayPalCommerce\ApiClient\Endpoint\Orders;
|
use WooCommerce\PayPalCommerce\ApiClient\Endpoint\Orders;
|
||||||
use WooCommerce\PayPalCommerce\ApiClient\Factory\PurchaseUnitFactory;
|
use WooCommerce\PayPalCommerce\ApiClient\Factory\PurchaseUnitFactory;
|
||||||
use WooCommerce\PayPalCommerce\Button\Exception\RuntimeException;
|
use WooCommerce\PayPalCommerce\Button\Exception\RuntimeException;
|
||||||
|
use WooCommerce\PayPalCommerce\WcGateway\Gateway\PayPalGateway;
|
||||||
use WooCommerce\PayPalCommerce\WcGateway\Gateway\TransactionUrlProvider;
|
use WooCommerce\PayPalCommerce\WcGateway\Gateway\TransactionUrlProvider;
|
||||||
use WooCommerce\PayPalCommerce\WcGateway\Processor\RefundProcessor;
|
use WooCommerce\PayPalCommerce\WcGateway\Processor\RefundProcessor;
|
||||||
|
|
||||||
|
@ -177,6 +178,9 @@ class BancontactGateway extends WC_Payment_Gateway {
|
||||||
|
|
||||||
$body = json_decode( $response['body'] );
|
$body = json_decode( $response['body'] );
|
||||||
|
|
||||||
|
$wc_order->update_meta_data( PayPalGateway::ORDER_ID_META_KEY, $body->id );
|
||||||
|
$wc_order->save_meta_data();
|
||||||
|
|
||||||
$payer_action = '';
|
$payer_action = '';
|
||||||
foreach ( $body->links as $link ) {
|
foreach ( $body->links as $link ) {
|
||||||
if ( $link->rel === 'payer-action' ) {
|
if ( $link->rel === 'payer-action' ) {
|
||||||
|
|
|
@ -13,6 +13,7 @@ use WC_Payment_Gateway;
|
||||||
use WooCommerce\PayPalCommerce\ApiClient\Endpoint\Orders;
|
use WooCommerce\PayPalCommerce\ApiClient\Endpoint\Orders;
|
||||||
use WooCommerce\PayPalCommerce\ApiClient\Factory\PurchaseUnitFactory;
|
use WooCommerce\PayPalCommerce\ApiClient\Factory\PurchaseUnitFactory;
|
||||||
use WooCommerce\PayPalCommerce\Button\Exception\RuntimeException;
|
use WooCommerce\PayPalCommerce\Button\Exception\RuntimeException;
|
||||||
|
use WooCommerce\PayPalCommerce\WcGateway\Gateway\PayPalGateway;
|
||||||
use WooCommerce\PayPalCommerce\WcGateway\Gateway\TransactionUrlProvider;
|
use WooCommerce\PayPalCommerce\WcGateway\Gateway\TransactionUrlProvider;
|
||||||
use WooCommerce\PayPalCommerce\WcGateway\Processor\RefundProcessor;
|
use WooCommerce\PayPalCommerce\WcGateway\Processor\RefundProcessor;
|
||||||
|
|
||||||
|
@ -178,6 +179,9 @@ class BlikGateway extends WC_Payment_Gateway {
|
||||||
|
|
||||||
$body = json_decode( $response['body'] );
|
$body = json_decode( $response['body'] );
|
||||||
|
|
||||||
|
$wc_order->update_meta_data( PayPalGateway::ORDER_ID_META_KEY, $body->id );
|
||||||
|
$wc_order->save_meta_data();
|
||||||
|
|
||||||
$payer_action = '';
|
$payer_action = '';
|
||||||
foreach ( $body->links as $link ) {
|
foreach ( $body->links as $link ) {
|
||||||
if ( $link->rel === 'payer-action' ) {
|
if ( $link->rel === 'payer-action' ) {
|
||||||
|
|
|
@ -13,6 +13,7 @@ use WC_Payment_Gateway;
|
||||||
use WooCommerce\PayPalCommerce\ApiClient\Endpoint\Orders;
|
use WooCommerce\PayPalCommerce\ApiClient\Endpoint\Orders;
|
||||||
use WooCommerce\PayPalCommerce\ApiClient\Factory\PurchaseUnitFactory;
|
use WooCommerce\PayPalCommerce\ApiClient\Factory\PurchaseUnitFactory;
|
||||||
use WooCommerce\PayPalCommerce\Button\Exception\RuntimeException;
|
use WooCommerce\PayPalCommerce\Button\Exception\RuntimeException;
|
||||||
|
use WooCommerce\PayPalCommerce\WcGateway\Gateway\PayPalGateway;
|
||||||
use WooCommerce\PayPalCommerce\WcGateway\Gateway\TransactionUrlProvider;
|
use WooCommerce\PayPalCommerce\WcGateway\Gateway\TransactionUrlProvider;
|
||||||
use WooCommerce\PayPalCommerce\WcGateway\Processor\RefundProcessor;
|
use WooCommerce\PayPalCommerce\WcGateway\Processor\RefundProcessor;
|
||||||
|
|
||||||
|
@ -177,6 +178,9 @@ class EPSGateway extends WC_Payment_Gateway {
|
||||||
|
|
||||||
$body = json_decode( $response['body'] );
|
$body = json_decode( $response['body'] );
|
||||||
|
|
||||||
|
$wc_order->update_meta_data( PayPalGateway::ORDER_ID_META_KEY, $body->id );
|
||||||
|
$wc_order->save_meta_data();
|
||||||
|
|
||||||
$payer_action = '';
|
$payer_action = '';
|
||||||
foreach ( $body->links as $link ) {
|
foreach ( $body->links as $link ) {
|
||||||
if ( $link->rel === 'payer-action' ) {
|
if ( $link->rel === 'payer-action' ) {
|
||||||
|
|
|
@ -13,6 +13,7 @@ use WC_Payment_Gateway;
|
||||||
use WooCommerce\PayPalCommerce\ApiClient\Endpoint\Orders;
|
use WooCommerce\PayPalCommerce\ApiClient\Endpoint\Orders;
|
||||||
use WooCommerce\PayPalCommerce\ApiClient\Factory\PurchaseUnitFactory;
|
use WooCommerce\PayPalCommerce\ApiClient\Factory\PurchaseUnitFactory;
|
||||||
use WooCommerce\PayPalCommerce\Button\Exception\RuntimeException;
|
use WooCommerce\PayPalCommerce\Button\Exception\RuntimeException;
|
||||||
|
use WooCommerce\PayPalCommerce\WcGateway\Gateway\PayPalGateway;
|
||||||
use WooCommerce\PayPalCommerce\WcGateway\Gateway\TransactionUrlProvider;
|
use WooCommerce\PayPalCommerce\WcGateway\Gateway\TransactionUrlProvider;
|
||||||
use WooCommerce\PayPalCommerce\WcGateway\Processor\RefundProcessor;
|
use WooCommerce\PayPalCommerce\WcGateway\Processor\RefundProcessor;
|
||||||
|
|
||||||
|
@ -179,6 +180,9 @@ class IDealGateway extends WC_Payment_Gateway {
|
||||||
|
|
||||||
$body = json_decode( $response['body'] );
|
$body = json_decode( $response['body'] );
|
||||||
|
|
||||||
|
$wc_order->update_meta_data( PayPalGateway::ORDER_ID_META_KEY, $body->id );
|
||||||
|
$wc_order->save_meta_data();
|
||||||
|
|
||||||
$payer_action = '';
|
$payer_action = '';
|
||||||
foreach ( $body->links as $link ) {
|
foreach ( $body->links as $link ) {
|
||||||
if ( $link->rel === 'payer-action' ) {
|
if ( $link->rel === 'payer-action' ) {
|
||||||
|
|
|
@ -13,6 +13,7 @@ use WC_Payment_Gateway;
|
||||||
use WooCommerce\PayPalCommerce\ApiClient\Endpoint\Orders;
|
use WooCommerce\PayPalCommerce\ApiClient\Endpoint\Orders;
|
||||||
use WooCommerce\PayPalCommerce\ApiClient\Factory\PurchaseUnitFactory;
|
use WooCommerce\PayPalCommerce\ApiClient\Factory\PurchaseUnitFactory;
|
||||||
use WooCommerce\PayPalCommerce\Button\Exception\RuntimeException;
|
use WooCommerce\PayPalCommerce\Button\Exception\RuntimeException;
|
||||||
|
use WooCommerce\PayPalCommerce\WcGateway\Gateway\PayPalGateway;
|
||||||
use WooCommerce\PayPalCommerce\WcGateway\Gateway\TransactionUrlProvider;
|
use WooCommerce\PayPalCommerce\WcGateway\Gateway\TransactionUrlProvider;
|
||||||
use WooCommerce\PayPalCommerce\WcGateway\Processor\RefundProcessor;
|
use WooCommerce\PayPalCommerce\WcGateway\Processor\RefundProcessor;
|
||||||
|
|
||||||
|
@ -180,6 +181,9 @@ class MultibancoGateway extends WC_Payment_Gateway {
|
||||||
|
|
||||||
WC()->cart->empty_cart();
|
WC()->cart->empty_cart();
|
||||||
|
|
||||||
|
$wc_order->update_meta_data( PayPalGateway::ORDER_ID_META_KEY, $body->id );
|
||||||
|
$wc_order->save_meta_data();
|
||||||
|
|
||||||
return array(
|
return array(
|
||||||
'result' => 'success',
|
'result' => 'success',
|
||||||
'redirect' => esc_url( $payer_action ),
|
'redirect' => esc_url( $payer_action ),
|
||||||
|
|
|
@ -13,6 +13,7 @@ use WC_Payment_Gateway;
|
||||||
use WooCommerce\PayPalCommerce\ApiClient\Endpoint\Orders;
|
use WooCommerce\PayPalCommerce\ApiClient\Endpoint\Orders;
|
||||||
use WooCommerce\PayPalCommerce\ApiClient\Factory\PurchaseUnitFactory;
|
use WooCommerce\PayPalCommerce\ApiClient\Factory\PurchaseUnitFactory;
|
||||||
use WooCommerce\PayPalCommerce\Button\Exception\RuntimeException;
|
use WooCommerce\PayPalCommerce\Button\Exception\RuntimeException;
|
||||||
|
use WooCommerce\PayPalCommerce\WcGateway\Gateway\PayPalGateway;
|
||||||
use WooCommerce\PayPalCommerce\WcGateway\Gateway\TransactionUrlProvider;
|
use WooCommerce\PayPalCommerce\WcGateway\Gateway\TransactionUrlProvider;
|
||||||
use WooCommerce\PayPalCommerce\WcGateway\Processor\RefundProcessor;
|
use WooCommerce\PayPalCommerce\WcGateway\Processor\RefundProcessor;
|
||||||
|
|
||||||
|
@ -177,6 +178,9 @@ class MyBankGateway extends WC_Payment_Gateway {
|
||||||
|
|
||||||
$body = json_decode( $response['body'] );
|
$body = json_decode( $response['body'] );
|
||||||
|
|
||||||
|
$wc_order->update_meta_data( PayPalGateway::ORDER_ID_META_KEY, $body->id );
|
||||||
|
$wc_order->save_meta_data();
|
||||||
|
|
||||||
$payer_action = '';
|
$payer_action = '';
|
||||||
foreach ( $body->links as $link ) {
|
foreach ( $body->links as $link ) {
|
||||||
if ( $link->rel === 'payer-action' ) {
|
if ( $link->rel === 'payer-action' ) {
|
||||||
|
|
|
@ -13,6 +13,7 @@ use WC_Payment_Gateway;
|
||||||
use WooCommerce\PayPalCommerce\ApiClient\Endpoint\Orders;
|
use WooCommerce\PayPalCommerce\ApiClient\Endpoint\Orders;
|
||||||
use WooCommerce\PayPalCommerce\ApiClient\Factory\PurchaseUnitFactory;
|
use WooCommerce\PayPalCommerce\ApiClient\Factory\PurchaseUnitFactory;
|
||||||
use WooCommerce\PayPalCommerce\Button\Exception\RuntimeException;
|
use WooCommerce\PayPalCommerce\Button\Exception\RuntimeException;
|
||||||
|
use WooCommerce\PayPalCommerce\WcGateway\Gateway\PayPalGateway;
|
||||||
use WooCommerce\PayPalCommerce\WcGateway\Gateway\TransactionUrlProvider;
|
use WooCommerce\PayPalCommerce\WcGateway\Gateway\TransactionUrlProvider;
|
||||||
use WooCommerce\PayPalCommerce\WcGateway\Processor\RefundProcessor;
|
use WooCommerce\PayPalCommerce\WcGateway\Processor\RefundProcessor;
|
||||||
|
|
||||||
|
@ -178,6 +179,9 @@ class P24Gateway extends WC_Payment_Gateway {
|
||||||
|
|
||||||
$body = json_decode( $response['body'] );
|
$body = json_decode( $response['body'] );
|
||||||
|
|
||||||
|
$wc_order->update_meta_data( PayPalGateway::ORDER_ID_META_KEY, $body->id );
|
||||||
|
$wc_order->save_meta_data();
|
||||||
|
|
||||||
$payer_action = '';
|
$payer_action = '';
|
||||||
foreach ( $body->links as $link ) {
|
foreach ( $body->links as $link ) {
|
||||||
if ( $link->rel === 'payer-action' ) {
|
if ( $link->rel === 'payer-action' ) {
|
||||||
|
|
|
@ -13,6 +13,7 @@ use WC_Payment_Gateway;
|
||||||
use WooCommerce\PayPalCommerce\ApiClient\Endpoint\Orders;
|
use WooCommerce\PayPalCommerce\ApiClient\Endpoint\Orders;
|
||||||
use WooCommerce\PayPalCommerce\ApiClient\Factory\PurchaseUnitFactory;
|
use WooCommerce\PayPalCommerce\ApiClient\Factory\PurchaseUnitFactory;
|
||||||
use WooCommerce\PayPalCommerce\Button\Exception\RuntimeException;
|
use WooCommerce\PayPalCommerce\Button\Exception\RuntimeException;
|
||||||
|
use WooCommerce\PayPalCommerce\WcGateway\Gateway\PayPalGateway;
|
||||||
use WooCommerce\PayPalCommerce\WcGateway\Gateway\TransactionUrlProvider;
|
use WooCommerce\PayPalCommerce\WcGateway\Gateway\TransactionUrlProvider;
|
||||||
use WooCommerce\PayPalCommerce\WcGateway\Processor\RefundProcessor;
|
use WooCommerce\PayPalCommerce\WcGateway\Processor\RefundProcessor;
|
||||||
|
|
||||||
|
@ -177,6 +178,9 @@ class TrustlyGateway extends WC_Payment_Gateway {
|
||||||
|
|
||||||
$body = json_decode( $response['body'] );
|
$body = json_decode( $response['body'] );
|
||||||
|
|
||||||
|
$wc_order->update_meta_data( PayPalGateway::ORDER_ID_META_KEY, $body->id );
|
||||||
|
$wc_order->save_meta_data();
|
||||||
|
|
||||||
$payer_action = '';
|
$payer_action = '';
|
||||||
foreach ( $body->links as $link ) {
|
foreach ( $body->links as $link ) {
|
||||||
if ( $link->rel === 'payer-action' ) {
|
if ( $link->rel === 'payer-action' ) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue