I create a APP in which i use Braintree Payment Gateway. In my application i make options to set different currency, am just know that how to set currency when i set sale transaction param.
here is my code
$result = Braintree\Transaction::sale([
'amount' => '50.00',
'creditCard' => array(
'cardholderName' => 'Test Name',
'number' => '4000111111111511',
'expirationDate' => '12/2018',
'cvv' => '123',
),
'options' => [ 'submitForSettlement' => true]
]);
All of my transaction made in US Dollar, but i want to make transaction in different currencies.
Please someone give me the solution.
thanks
Full disclosure: I work at Braintree. If you have any further questions, feel free to contact support.
You will need to set up a different merchant account for each currency you would like to process. Then, when processing a transaction for a specific currency, you can pass in the merchant account id to the transaction sale method.
In addition, to keep your PCI compliance burden low, you will want to pass a nonce to your server in place of the credit card details.
$merchantAccountId = someFunctionToLookupCorrectMerchantIdBasedOnCurrency();
$result = Braintree\Transaction::sale([
'amount' => '100.00',
'paymentMethodNonce' => nonceFromTheClient,
'merchantAccountId' => $merchantAccountId,
'options' => [
'submitForSettlement' => True
]
]);
Related
I have implemented the Stripe SCA migration
my serve side code to create payment intent is as follows
$intent = \Stripe\PaymentIntent::create([
'payment_method' => $requestData['payment_method_id'],
'amount' => $requestData->amount,
'currency' => $requestData->currencyIso,
'payment_method_types' => ['card'],
'confirmation_method' => "manual",
'confirm' => true,
'setup_future_usage'=>"off_session",
]);
return $intent;
And my js code is as below to create card payment and handle response
stripe.createPaymentMethod('card', cardElement, {
billing_details: {name: cardholderName.value}
})
and handle the response:
function handleServerResponse(response) {
if (response.error) {
} else if (response.requires_action) {
stripe.handleCardAction(
response.payment_intent_client_secret
).then(function(result) {
if (result.error) {
} else {
// The card action has been handled
// The PaymentIntent can be confirmed again on the server
fetch('https://test.com/server.php', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
payment_method_id: result.paymentMethod.id,
amount: amount
})
}).then(function(confirmResult) {
console.log(confirmResult);
return confirmResult.json();
}).then(handleServerResponse);
}
});
}
}
}
$plan = Plan::create([
'currency' => $currency,
'interval' => 'month',
'product' => $product->id,
'nickname' => 'Payment Plan for order - ' . $order_id,
'amount' => $price,
'metadata' => [
'order_number' => $order_id,
'bgt_customer_number' => $customer_id,
],
]);
$schedule = SubscriptionSchedule::create([
'customer' => $customer->id,
'start_date' => 'now',
'end_behavior' => 'cancel',
'metadata' => [
'local_id' => $order_id,
'local_account_id' => $account_id,
'local_currency_id' => $currency_id,
'local_user_id'=> $user_id,
'local_installments_total' => $plan_length,
'bgt_customer_number' => $customer_id,
'order_number' => $order_id,
'invoice_description' => 'Payment Plan for order - ' . $order_id
],
'phases' => [
[
'items' => [
[
'plan' => $plan->id,
],
],
'collection_method'=> 'charge_automatically',
'iterations'=>$plan_length
],
],
]);
$metadata = [
'installments_paid' => '0',
'installments_total' => $plan_length,
'local_id' =>$order_id,
'local_account_id' =>$account_id,
'local_currency_id' =>$currency_id,
'subscription_schedule_id' => $schedule->id
];
$subscription_id=$schedule->subscription;
$result=Subscription::update($subscription_id,
[
'metadata' => $metadata,
'default_payment_method' => $paymentMethodParams['payment_method'],
'proration_behavior' =>'always_invoice',
//Create only after adding payment method id in customer
]
);
I am getting the SCA modal for sca cards and workflow is correct.
But what concerns me is testing the subscription created using sca
I tested using 4000000000003220 amd also 424242424242424.. and subscription is created with 3 installments.
The subscription is created with correct installments:
But what concerns me is the subscription first installment is not being charged immediately.
Invoice shows as:
This draft invoice was generated by a subscription. It can be edited
until it's automatically finalized in 1 hour.
.
When I try to complete the charge from stripe dashboard (as a part of test) it shows
The invoice was finalized, but the customer needs to complete 3D
Secure authentication for the payment to succeed. This additional
step is required by their bank to prevent fraud. 3D Secure emails are
disabled in your settings, so you'll need to notify the customer
manually
The invoice failed to capture.
Question:
1: I wanted the first installment or schedule to happen.
How do I accomplish this in staging env. Am I missing any points here in creating subscription or SCA methods?
2: What is really 'confirmation_method' => "manual". Really confused.
When using Stripe Subscriptions you typically won't be creating Payment Intents yourself. Instead you'll be creating and interacting with Billing objects like Subscriptions and Invoices. The Invoices will create the Payment Intents for you. Stripe has a guide that walks you through taking payment information and creating a Subscription. If you read through and follow that guide you should be able to build what you want.
To answer your specific questions:
Question: 1: I wanted the first installment or schedule to happen. How do I accomplish this in staging env. Am I missing any points here in creating subscription or SCA methods?
This is likely because you're creating a Payment Intent and paying that which is unrelated to the Payment Intent belonging to the Invoice of your Subscription.
2: What is really 'confirmation_method' => "manual". Really confused.
The confirmation_method property controls how a Payment Intent can be confirmed. However, if you're using Subscriptions and want to support SCA you should ignore this property and instead follow the guide linked above.
I need help with the kraken API. I have created the connection and I am able to trade various pairs but now I need to make an automatic withdraw using their API. For the trading pairs I have the following running which buys 0.002 BTC using EURO
$res = $kraken->QueryPrivate('AddOrder', array(
'pair' => 'XBTEUR',
'type' => 'sell',
'ordertype' => 'market',
'volume' => '0.002',
));
print_r($res);
Now... how do I withdraw 0.002 btc using the api and sending these to my wallet: 1BujYrWGkzFdmecXUNgj8nE13gwXtxZxKZ
I can't seem to find this specific information anywhere :(
To answer my own question, this was the code I needed:
$res = $kraken->QueryPrivate('Withdraw', array(
'asset' => 'XBT',
'key' => 'withdrawal key name here',
'amount' => '0.002',
));
print_r($res);
Where as the key, was the name of the account which contained the wallet I wanted to withdraw fund to.
I have implemented PHP braintree API in a project, I want to use Marketplace api for the same.
Now, we have promotional events and we do not charge client, but we have to pay amount to sub-merchant who has delivered goods.
So below is the code to add service fees, which is clear that at the time of sale we have to add sub-merchant id for merchantAccountId, amount will be payment charged from client, what is paymentMethodNonce?
$result = Braintree_Transaction::sale(array(
'merchantAccountId' => 'provider_sub_merchant_account',
'amount' => '10.00',
'paymentMethodNonce' => 'nonce-from-the-client',
'serviceFeeAmount' => "1.00"
));
Another query is, at the time of sale we have to pass credit card details of the client? What if client is already in vault ?
Below is another code from Braintree document with creditCard details
$result = Braintree_Transaction::sale(
array(
'amount' => "100",
'merchantAccountId' => "blue_ladders_store",
'creditCard' => array(
'number' => "4111111111111111",
'expirationDate' => "12/20",
),
'options' => array(
'submitForSettlement' => true,
'holdInEscrow' => true,
),
'serviceFeeAmount' => "10.00"
)
);
If we do not add creditCard number and have to pay sub-merchant then how can that be done.
Thanks
Recently I'm playing with paypal API PHP.
I have downloaded a code from this url.
https://github.com/paypal/rest-api-curlsamples/blob/master/execute_all_calls.php
The code really works good with test creditcard(type:mastercard). The code looks like this
$url = $host.'/v1/payments/payment';
$payment = array(
'intent' => 'sale',
'payer' => array(
'payment_method' => 'credit_card',
'funding_instruments' => array ( array(
'credit_card' => array (
'number' => '540xxxxxxxxxxxx6',
'type' => 'mastercard',
'expire_month' => 12,
'expire_year' => 2018,
'cvv2' => 111,
'first_name' => 'First Name',
'last_name' => 'Last Name'
)
))
),
'transactions' => array (array(
'amount' => array(
'total' => '2',
'currency' => 'USD'
),
'description' => 'payment by a credit card using a test script'
))
);
Now if i try to use the same code to make the payment using my VISA(American Express) with test card number 37xxxxxxxxxx005, how shall i obtain this? What are the parameters to be altered?
In other words I would like to make the payment using Diner's Club,Discover and JCB. How shall I achieve this?
Edit: I have got two comments from Stack Overflow users, and you can check it at the bottom of my question. I'm not clear with the comments. Do they tell that I don't need to think about the parameters and paypal will take care of the card details and make the transaction?
Got reply from Paypal Tech Team for my above question
{snip}
You need to alter the code for 'type'. Below shows the code for the credit card type :l
- Visa
- MasterCard
- Discover
- Amex
And also make sure you need to input correct credit card number based on the type if you not you will receive an error message.
{/snip}
In other words, it is more than enough if I change the 'type' => 'mastercard' to 'type' => 'visa' (or) 'type' => 'amex' (or) 'type' => 'discover'
And also please make sure you give the correct test card numbers. You can view the dummy credit card numbers here.
http://www.paypalobjects.com/en_US/vhelp/paypalmanager_help/credit_card_numbers.htm
Hope this will help someone if they are struck with the paypal PHP API integration.
Thanks for all the tech support & SOF-Users.
Thanks again,
Haan
I am working with the PayPal RESTful API.
https://developer.paypal.com/webapps/developer/docs/api/
How can I pass my consumers order items and purchase description to PayPal, so when my user is redirected to PayPal to approve the order by logging in, their order summary will show up on the left.
.
.
ORDER SUMMARY ON THE LEFT
I have tried to passing in the transactions.item_list.items but that information isn't showing up in the order summary still.
Any help how to get an order summary to appear on the paypal approval page using the PayPal RESTful API?
I haven't been to pleased with their documentation as it is lacking some information and also has a few mistakes which wasted decent amount of my time to debug.
//
// prepare paypal data
$payment = array(
'intent' => 'sale',
'redirect_urls' => array(
'return_url' => $url_success,
'cancel_url' => $url_cancel,
),
'payer' => array(
'payment_method' => 'paypal'
)
);
//
// prepare basic payment details
$payment['transactions'][0] = array(
'amount' => array(
'total' => '0.03',
'currency' => 'USD',
'details' => array(
'subtotal' => '0.02',
'tax' => '0.00',
'shipping' => '0.01'
)
),
'description' => 'This is the payment transaction description 1.'
);
//
// prepare individual items
$payment['transactions'][0]['item_list']['items'][] = array(
'quantity' => '1',
'name' => 'Womens Large',
'price' => '0.01',
'currency' => 'USD',
'sku' => '31Wf'
);
$payment['transactions'][0]['item_list']['items'][] = array(
'quantity' => '1',
'name' => 'Womens Medium',
'price' => '0.01',
'currency' => 'USD',
'sku' => '31WfW'
);
//
//format payment array to pass to cURL
$CURL_POST = json_encode($payment);
your code is good. This is actually a bug that will be fixed very soon. Regarding documentation, can you share how we can make it better? I want to make sure your feedback gets passed to our documentation team.
I experienced the same issue while trying it out today. What I did was add the Items like below.
$item = new Item();
$item->setQuantity($item_quantity);
$item->setName($item_name);
$item->setPrice($item_price);
$item->setCurrency($item_currency);
$item_list = new ItemList();
$item_list->setItems(array($item));
The $item_list is a property of transaction so you should add it after.
$transaction = new Transaction();
$transaction->setItemList($item_list);
....
That should show on the Order summary pane on PayPal page.
You can also check the answer here.
Try using the sample shown here : http://htmlpreview.github.io/?https://raw.githubusercontent.com/paypal/PayPal-PHP-SDK/master/sample/doc/payments/CreatePaymentUsingPayPal.html
It is a sample that comes along with the PayPal REST API SDK. You can try those samples out yourselves, by following instructions on readme.
This is how it would look like, when you run that sample: