$ENDPOINT = 'https://api-3t.sandbox.paypal.com/nvp'; } $VERSION = '65.1'; //must be >= 65.1 //Build the Credential String: $cred_str = 'USER='******'&PWD=' . $APIPASSWORD . '&SIGNATURE=' . $APISIGNATURE . '&VERSION=' . $VERSION; //Build NVP String for GetExpressCheckoutDetails $nvp_str = '&METHOD=GetExpressCheckoutDetails&TOKEN=' . urldecode($token); //combine the two strings and make the API Call $req_str = $cred_str . $nvp_str; $response = Paypal::httpPost($ENDPOINT, $req_str); //based on the API Response from GetExpressCheckoutDetails $doec_str = $cred_str . '&METHOD=DoExpressCheckoutPayment' . '&TOKEN=' . $token . '&PAYERID=' . $payerid . '&PAYMENTREQUEST_0_CURRENCYCODE=' . urldecode($response['PAYMENTREQUEST_0_CURRENCYCODE']) . '&PAYMENTREQUEST_0_AMT=' . urldecode($response['PAYMENTREQUEST_0_AMT']) . '&PAYMENTREQUEST_0_ITEMAMT=' . urldecode($response['PAYMENTREQUEST_0_ITEMAMT']) . '&PAYMENTREQUEST_0_TAXAMT=' . urldecode($response['PAYMENTREQUEST_0_TAXAMT']) . '&PAYMENTREQUEST_0_DESC=' . urldecode($response['PAYMENTREQUEST_0_DESC']) . '&PAYMENTREQUEST_0_PAYMENTACTION=Sale' . '&L_PAYMENTREQUEST_0_ITEMCATEGORY0=' . urldecode($response['L_PAYMENTREQUEST_0_ITEMCATEGORY0']) . '&L_PAYMENTREQUEST_0_NAME0=' . urldecode($response['L_PAYMENTREQUEST_0_NAME0']) . '&L_PAYMENTREQUEST_0_NUMBER0=' . urldecode($response['L_PAYMENTREQUEST_0_NUMBER0']) . '&L_PAYMENTREQUEST_0_QTY0=' . urldecode($response['L_PAYMENTREQUEST_0_QTY0']) . '&L_PAYMENTREQUEST_0_TAXAMT0=' . urldecode($response['L_PAYMENTREQUEST_0_TAXAMT0']) . '&L_PAYMENTREQUEST_0_AMT0=' . urldecode($response['L_PAYMENTREQUEST_0_AMT0']) . '&L_PAYMENTREQUEST_0_DESC0=' . urldecode($response['L_PAYMENTREQUEST_0_DESC0']) . '&NOTIFYURL='; //make the DoEC Call: $doresponse = Paypal::httpPost($ENDPOINT, $doec_str); $status = Paypal::processDGPayment($doresponse, $response); $product_type = explode('x', urldecode($response['L_PAYMENTREQUEST_0_NUMBER0'])); if ($status == PAYMENT_COMPLETED || $status == PAYMENT_ALREADY_PAID) { osc_add_flash_ok_message(__('Payment processed correctly', 'payment')); if ($product_type[0] == '101') { $item = Item::newInstance()->findByPrimaryKey($product_type[2]); $category = Category::newInstance()->findByPrimaryKey($item['fk_i_category_id']); View::newInstance()->_exportVariableToView('category', $category); $html = '<p>' . __('Payment processed correctly', 'payment') . ' <a href=\\"' . osc_search_category_url() . '\\">' . __('Click here to continue', 'payment') . '</a></p>'; $url = osc_search_category_url(); } else { if ($product_type[0] == '201') { $html = '<p>' . __('Payment processed correctly', 'payment') . ' <a href=\\"' . payment_js_redirect_to(osc_route_url('payment-user-menu')) . '\\">' . __("Click here to continue", 'payment') . '</a></p>'; $url = payment_js_redirect_to(osc_route_url('payment-user-menu')); } else { $html = '<p>' . __('Payment processed correctly', 'payment') . ' <a href=\\"' . payment_js_redirect_to(osc_route_url('payment-user-pack')) . '\\">' . __("Click here to continue", 'payment') . '</a></p>';