Paypal Checkout SDK - immediate payment - php

I need to use Paypal checkout in order to accept immediate payment on my Laravel website, and I switched from old Paypal PHP SDK to the new Paypal checkout SDK to support API V2.
I followed the samples codes that provided in the new SDK, I have to create all workflow on my server, so I created an order with intent=CAPTURE with other required fields.
$request = new OrdersCreateRequest();
$request->headers["prefer"] = "return=representation";
$request->body = $this->buildMinimumRequestBody(...);
$response = $this->client->execute($request);
// redirect the user to approval link.
Order body:
return array(
'intent' => 'CAPTURE',
'application_context' =>
array(
'return_url' => 'https://example.com/return',
'cancel_url' => 'https://example.com/cancel',
'locale' => 'en-US',
'user_action' => 'PAY_NOW',
'shipping_preference'=> 'NO_SHIPPING'
),
'purchase_units' =>
array(
0 =>
array(
'amount' =>
array(
'currency_code' => 'USD',
'value' => 12,
'breakdown' =>
array(
'item_total' =>
array(
'currency_code' => 'USD',
'value' => 10,
),
'tax_total' =>
array(
'currency_code' => 'USD',
'value' => 2,
),
),
),
),
),
);
After the user redirected to approval URL and approving it, I execute the payment like below:
$response = $this->client->execute(new OrdersCaptureRequest($payment_id));
Below is the response after executing the payment.
Order and Payment response
So after directing the user to the approval page, then after approving the payment, then executing the order, I got the above result in the attached screenshot which shows the Order status is completed but the payment status is still "pending" and the reason is "PENDING_REVIEW", so I would like to ask if there is any error or something missed to make the payment immediately without waiting for review with an example.
Thanks.

Related

Stripe saying 'Payment not completed' Stripe connect php

When transferring money to a connected account on Stripe using this code
// // Create a PaymentIntent:
$method = \Stripe\PaymentMethod::create([
'type' => 'card',
'card' => [
'number' => '4242424242424242',
'exp_month' => 12,
'exp_year' => 2020,
'cvc' => '314',
],
]);
$paymentIntent = \Stripe\PaymentIntent::create([
'amount' => $AMOUNT1,
'currency' => 'nzd',
'payment_method_types' => ['card'],
'payment_method' => $method->id,
'customer' => CUSTOMER_ID,
'transfer_group' => '{ORDER'.$_SESSION['order_id'].'}',
]);
// Create a Transfer to a connected account (later):
$transfer = \Stripe\Transfer::create([
'amount' => $AMOUNT2,
'currency' => 'nzd',
'destination' => $ACC_ID,
'transfer_group' => '{ORDER'.$_SESSION['order_id'].'}',
]);
The payment stores on the connected account's dashboard and says its completed but when it stores on my Payments tab it says that the payment is incomplete and that the buyer has not completed the payment
Prev1
Prev2
You need to confirm the payment intent, either by providing confirm=true at creation or by making a call to /confirm.
You're creating a transfer from your account to the connected one, which succeeds, and a payment that you never complete.

Pay out using stripe with card

I am creating a project using stripe and php. I am integrating the stripe and transfer the amount to the card.I am following the offical document of stripe and getting some error
$payout = \Stripe\Payout::create([
'amount' => 1000,
'currency' => 'usd',
'method' => 'instant',
'destination' => 'card_xyz',
]);
Getting Error:
No such external account: 19173966
https://stripe.com/docs/payouts
You need to include source_type in the request. See if the account already exists.
$payout = \Stripe\Payout::create([
'amount' => 1000,
'currency' => 'usd',
'method' => 'instant',
'destination' => 'card_xyz',
'source_type' => 'card',
]);

Hipay payment Gateway integration Response in php

I'm using a hipay wallet test account and used there webservices to integrate. Transaction is working fine but problem is that i'm not getting the response in the page, it is suppossed to get in $_POST['xml'] on the response page
$setUrlAck =show_page_link("payment/hipay_new/response.php",true);
Below is my code
if ($PaymentDetails['sel_payment_env'] == 1) {
$wsdl = 'https://ws.hipay.com/soap/subscription?wsdl'; //for live
} else {
$wsdl = 'https://test-ws.hipay.com/soap/subscription?wsdl';//for testing
}
// If the payment is accepted, the user will be redirected to this page
$setURLOk= show_page_link(FILE_THANKS."?add=success&OrderNo=".$orderid,true);
// If the payment is refused, the user will be redirected to this page
$setUrlNok=show_page_link(FILE_THANKS."?cancleMsg=true",true);
// If the user cancels the payment, he will be redirected to this page
$setUrlCancel=show_page_link(FILE_THANKS."?cancleMsg=true",true);
// The merchant?s site will be notified of the result of the payment by a call to the script
$setUrlAck =show_page_link("payment/hipay_new/response.php",true);
$initArray = array(
'wsLogin' => $wsLogin, // Your wsLogin
'wsPassword' => $wspassword, // Your wsPassword
'websiteId' => $txt_Merchant, // Your webSiteId
'categoryId' => $PaymentDetails['txt_category_id'], // Your website category ID (https://test-payment.hipay.com/order/list-categories/id/(websiteId))
'customerEmail' => $customer_email, // Your customers' email
);
$options = array(
'compression' => SOAP_COMPRESSION_ACCEPT | SOAP_COMPRESSION_GZIP,
'cache_wsdl' => WSDL_CACHE_NONE,
);
$client = new SoapClient($wsdl, $options);
$data = array(
'currency' => $currency_code,
'rating' => 'ALL',
'locale' => 'fr_FR',
'manualCapture' =>1,
'label' => 'My label is a Manged Subscrption Test Service ',
'customerIpAddress' => $_SERVER["REMOTE_ADDR"],
'merchantReference' => 'AZERTY',
'urlCallback' => $setUrlAck, // Here in this page i'm suppossed to get the response in $_POST
'urlAccept' => $setURLOk,
'urlCancel' =>$setUrlCancel,
'payments' => array(
'initial' => array(
'name' => 'Payment',
'description' => 'Payment for printing products',
'amount' => $price,
'subscriptionId' => 'QWERTY',
'periodType' => 'normal',
'recurrence' => array(
'frequency' => 0,
'duration' => 'managed'
),
),
),
);
Kindly guide me if anyone got through the same issues
The issue is solved, problem was that my firewall setting was blocking the response

Braintree payments Escrow Funding

I am trying to implement escrow funding using braintree in php. I have downloaded library from here. My code is below:-
require_once "../braintree/lib/Braintree.php";
Braintree_Configuration::environment("sandbox");
Braintree_Configuration::merchantId("was4zgn5x6vt99h");
Braintree_Configuration::publicKey("ydjrasdwyw9npkvnw4");
Braintree_Configuration::privateKey("f197ac5a66a1fsad37d3950890b2cbda9");
$result = Braintree_Transaction::sale(
array(
'amount' => "100.00",
'creditCard' => array(
'number' => "4111111111111111",
'expirationDate' => "12/2014",
),
'options' => array(
'submitForSettlement' => true,
'holdInEscrow' => true,
)
)
);
echo "<pre>";
print_r("\n message: " . $result->message);
It is working for direct payment. But It is not working for escrow. Please check my code.
Error is:-
"message: Transaction could not be held in escrow."
I have got the code from here
At last i got the actual answer from Braintree. I had to add two more parameters. One merchantAccountId and other is serviceFeeAmount. Here merchantAccountId id is actually sub merchant merchantAccountId. You will get merchantAccountId from Braintree. After logging in, go to settings->Processing. At the bottom of the page you will get View All Merchant Account. Here you will get merchantAccountId. Don't use default merchantAccountId it will not work.
require_once "../braintree/lib/Braintree.php";
Braintree_Configuration::environment("sandbox");
Braintree_Configuration::merchantId("was4zgn5x6vt99h");
Braintree_Configuration::publicKey("ydjrasdwyw9npkvnw4");
Braintree_Configuration::privateKey("f197ac5a66a1fsad37d3950890b2cbda9");
$result = Braintree_Transaction::sale(
array(
'amount' => "100.00",
'merchantAccountId' => 'test_user_instant_5vcgn574',
'creditCard' => array(
'number' => "4111111111111111",
'expirationDate' => "12/2014",
),
'options' => array(
'submitForSettlement' => true,
'holdInEscrow' => true,
),
'serviceFeeAmount' =>'1'
)
);
echo "<pre>";
print_r("\n message: " . $result->message);
I think that you need two things:
Pass a merchant_account_id - see example on https://www.braintreepayments.com/docs/php/transactions/escrow
You can only do escrow if your merchant account is using Marketplace. https://www.braintreepayments.com/docs/php/guide/marketplace
I think you made a mistake in your code:
'options' => array(
'submitForSettlement' => true,
'holdInEscrow' => true,
)
Should be:
'holdInEscrow' => true
There should be no comma after 'holdInEscrow' => true

"The Transaction is invalid ...." PayPal when I send user for approval

I am really in trouble from couple of hours, tried many ways but still no luck. I have integrated PayPal in my wordpress theme using Paypal Framework Wordpress plugin. The Sandbox settings are working fine. I got Success on SetExpressCheckout with Token, When I send user to PayPal for approval and payment using https://www.sandbox.paypal.com/webscr?TOKEN=EC-2FY692500K5578627&cmd=_express-checkout it gives me error...
This transaction is invalid. Please return to the recipient's website to complete your transaction using their regular checkout flow.
Please help, what can I do to make it work... I am really worried... :(
UPDATED
I am sending following params for SetExpressCheckout
$ppParams = array(
'METHOD' => 'SetExpressCheckout',
'PAYMENTREQUEST_0_PAYMENTACTION' => 'Sale',
'RETURNURL' => admin_url('admin-ajax.php?action=paypal_handler&step=commit&user_id=' . $user_id),
'CANCELURL' => home_url(),
'AMT' => $price,
'PAYMENTREQUEST_0_AMT' => $price,
'PAYMENTREQUEST_0_ITEMAMT' => $price,
'L_PAYMENTREQUEST_0_ITEMCATEGORY0' => 'Digital',
'L_PAYMENTREQUEST_0_NAME0' => 'Prod Name',
'L_PAYMENTREQUEST_0_QTY0' => 1,
'L_PAYMENTREQUEST_0_AMT0' => $price,
'DESC' => 'description',
'FIRSTNAME' => $_POST['first_name'],
'LASTNAME' => $_POST['last_name'],
'EMAIL' => $email
);
$response = hashCall($ppParams);
I am using following https://cms.paypal.com/uk/cgi-bin/?cmd=_render-content&content_ID=developer/e_howto_api_ECGettingStarted for cross checking and implementation.
Huh! found the solution... it was nothing just use lower-case letters for TOKEN... in https://www.sandbox.paypal.com/webscr?token=EC-2FY692500K5578627&cmd=_express-checkout

Categories