Automattic\WooCommerce\Gateways\PayPal
Request::get_approve_link
Get the approve link from the response data.
Method of the class: Request{}
No Hooks.
Returns
String|null.
Usage
// private - for code of main (parent) class only $result = $this->get_approve_link( $http_code, $response_data ): ?string;
- $http_code(int|string) (required)
- The HTTP code of the response.
- $response_data(array) (required)
- The response data.
Request::get_approve_link() Request::get approve link code WC 10.8.1
private function get_approve_link( $http_code, array $response_data ): ?string {
// See https://developer.paypal.com/docs/api/orders/v2/#orders_create.
if ( isset( $response_data['status'] ) && PayPalConstants::STATUS_PAYER_ACTION_REQUIRED === $response_data['status'] ) {
$rel = 'payer-action';
} else {
$rel = 'approve';
}
foreach ( $response_data['links'] as $link ) {
if ( $rel === $link['rel'] && 'GET' === $link['method'] && filter_var( $link['href'], FILTER_VALIDATE_URL ) ) {
return esc_url_raw( $link['href'] );
}
}
return null;
}