Braintree payments Escrow Funding - php

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

Related

Paypal Checkout SDK - immediate payment

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.

Problem while adding Journal Entry with customer in Quickbook - Message: Passed array has no key for 'Value' when contructing an ReferenceType

I go through this documentation "https://developer.intuit.com/app/developer/qbo/docs/api/accounting/all-entities/journalentry"
And tried to add journal entry with line having customer as shown in the below code:
$journal_entry_create['TxnDate'] = date('Y-m-d');
$journal_entry_line = array(
'Amount' => $amount,
'DetailType' => 'JournalEntryLineDetail',
'JournalEntryLineDetail' => array(
'PostingType' => Credit,
'Entity' => array(
'Type' => 'Customer',
'EntityRef' => array(
'type' => 'Customer',
'value' => "2",
'name' => 'Abc'
)
),
'AccountRef' => array(
'name' => 'Account Name',
'value' => '1'
),
)
);
$journal_entry_lines[] = $journal_entry_line;
$journal_entry_create['Line'] = $journal_entry_lines;
$journal_entry_receipt_create = QBJournalEntry::create($journal_entry_create);
$journal_entry_receipt_create_result = $dataService->Add($journal_entry_receipt_create);
Without EntityRef its working fine but when I add EntityRef its giving me error "Message: Passed array has no key for 'Value' when contructing an ReferenceType"
Only just came across this problem myself. They did fix this issue but didn't seem to document it at all or tell anyone. Found the fix in the source code. You need to use "JournalEntryEntity" instead of "Entity" under "JournalEntryLineDetail", like so:
'JournalEntryLineDetail' => array(
'PostingType' => "Credit",
'JournalEntryEntity' => array(
'Type' => 'Customer',
'EntityRef' => array(
'value' => "2"
)
),
'AccountRef' => array(
'name' => 'Account Name',
'value' => '1'
),
)
Also I used the FacadeHelper from the V3 of the PHP SDK (I'm not sure if it'll work with the method you were using):
use QuickBooksOnline\API\Facades\FacadeHelper;
...
$journal_entry_receipt_create = FacadeHelper::reflectArrayToObject('JournalEntry', $journal_entry_create);
$journal_entry_receipt_create_result = $dataService->Add($journal_entry_receipt_create);
I know this is probably too late for you OP but hopefully it helps someone else!

SugarCRM On-Demand Convert TextField to DropDown

A similar question was posted here before but it only applied to an On-Site SugarCRM instance (it was also a long time ago).
In my case I would like to change the "Billing Country" field from 'TextField' to 'DropDdown' on an On-Demand instance where I don't have access to the config files. How can I do this?
So far I have tried different PHP files using the Module Loader but it's not working either.
Please find my PHP script below:
<?php
$manifest = array(
'acceptable_sugar_flavors' => array('CE', 'PRO', 'CORP', 'ENT', 'ULT'),
'acceptable_sugar_versions' => array(
'exact_matches' => array(),
'regex_matches' => array(
0 => '6\\.5\\.(.*?)',
1 => '6\\.7\\.(.*?)',
2 => '7\\.2\\.(.*?)',
3 => '7\\.2\\.(.*?)\\.(.*?)',
4 => '7\\.5\\.(.*?)\\.(.*?)',
5 => '7\\.6\\.(.*?)\\.(.*?)'
),
),
'name' => 'Textfield to Dropdown',
'description' => 'Converting Billing Country textfield to Dropdown Field',
'author' => 'myname',
'icon' => '',
'is_uninstallable' => true,
'published_date' => '2015-01-09 19:00:00',
'type' => 'module',
'version' => '1.0',
);
$dictionary['Account']['fields']['billing_address_country']['type'] = 'enum';
$dictionary['Account']['fields']['billing_address_country']['ext1'] = 'countries_dom';
The module loads fine but there's no change after a Quick Repair. I have tried with the following variables, as well:
$dictionary['Account']['fields']['billing_address_country']['isDropDown']=yes;
and...
$dictionary['Account']['fields']['billing_address_country']['Options']='countries_dom';
Can anyone tell me what I am doing wrong? I'd appreciate any help or guidance you have. Please advise.
Cheers,
H
P.S. I am using SugarCRM On-Demand Version 7.6.1
You need to create the manifest.php file and have that point to the file(s) you want to copy/upload for customization:
manifest.php:
<?php
$manifest = array(
'built_in_version' => '7.6.1.0',
'acceptable_sugar_versions' =>
array(
0 => '',
),
'acceptable_sugar_flavors' =>
array(
0 => 'PRO',
1 => 'CORP',
2 => 'ENT',
3 => 'ULT',
),
'readme' => '',
'key' => 'SO',
'author' => 'Eric',
'description' => 'Convert Accounts Billing Country TextField to Enum',
'icon' => '',
'is_uninstallable' => true,
'name' => 'TextFieldToDropdownPkg',
'published_date' => '2016-01-10 03:01:01',
'type' => 'module',
'version' => 1452378413,
'remove_tables' => 'prompt',
);
$installdefs = array(
'id' => 'TextFieldToDropdownPkg',
'copy' => array(
0 => array(
'from' => '<basepath>/custom/Extension/modules/Accounts/Ext/Vardefs/custom_billing_address_country.php',
'to' => 'custom/Extension/modules/Accounts/Ext/Vardefs/custom_billing_address_country.php',
),
),
);
Then create:
custom/Extension/modules/Accounts/Ext/Vardefs/custom_billing_address_country.php
<?php
$dictionary['Account']['fields']['billing_address_country']['comments']='Country for primary address';
$dictionary['Account']['fields']['billing_address_country']['group']='primary_address';
$dictionary['Account']['fields']['billing_address_country']['options']='countries_dom';
$dictionary['Account']['fields']['billing_address_country']['type']='enum';
ZIP those files up and use Module Loader.

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

AWS PHP SDK issue with Dynamodb WriteRequestBatch

I am experimenting with WriteRequestBatch from AWS SDK for Dynamodb. Below is my code. Everything works except the WriteRequestBatch part. I have no clue why, and was wondering if the community could help me out here. What might I be doing wrong? I have tried googling and searching here and found only 8 other questions that could be related but unfortunately were of no help.
This is where I started from.
$ddb_client = DynamoDbClient::factory(array(
'region' => 'us-east-1',
'key' => 'my_key',
'secret' => 'my_secret'
));
$ddb_client->createTable(array(
'TableName' => 'my_table',
'AttributeDefinitions' => array(
array(
'AttributeName' => 'id',
'AttributeType' => 'S'
),
array(
'AttributeName' => 'ns',
'AttributeType' => 'S'
)
),
'KeySchema' => array(
array(
'AttributeName' => 'id',
'KeyType' => 'HASH'
),
array(
'AttributeName' => 'ns',
'KeyType' => 'RANGE'
)
),
'ProvisionedThroughput' => array(
'ReadCapacityUnits' => 10,
'WriteCapacityUnits' => 10
)
));
$response = $ddb_client->putItem(array(
"TableName" => "my_table",
"Item" => array(
"id" => array("S" => "exp_id"),
"ns" => array("S" => "exp_ns"),
"version" => array("N" => "0"),
),
));
$item = $response['Item'];
$item['version']['N'] = '1';
$put_batch = WriteRequestBatch::factory($ddb_client);
$put_request = new PutRequest(
array(
"Item" => $item,
"Expected" => array(
"version" => array(
"ComparisonOperator" => "EQ",
"AttributeValueList" => array(
array("N" => "0")
)
),
),
),
"my_table"
);
$putBatch->add($put_request);
$putBatch->flush();
This works instead of WriteRequestBatch. I will just have to manage batches to put myself than use WriteRequestBatch doing it for me:
$response = $ddb_client->batchWriteItem(array(
"RequestItems" => array(
"my_table" => array(
array(
"PutRequest" => array(
"Item" => $item,
"Expected" => array(
"version" => array(
"ComparisonOperator" => "EQ",
"AttributeValueList" => array(
array("S" => "0")
)
),
),
)
)
)
)
));
The answer by Geek Stocks is incomplete, but still helpful. One thing you can do handle the asynchronous aspects of the CreateTable operation is to use a Waiter:
$ddb_client->createTable(array('TableName' => 'my_table', ... ));
$ddb_client->waitUntil('TableExists', array('TableName' => 'my_table'));
However, there is also a problem with how you are using the WriteRequestBatch class. When you create a PutRequest, you must pass in the item, not a whole set of PutItem parameters. The WriteRequestBatch is an abstraction over DynamoDB's BatchWriteItem operation, which does not allow things like the Expected parameter. If you want to do that, then you need to use individual PutItem/UpdateItem/DeleteItem requests.
Here is a modified version of your usage of WriteRequestBatch that is correct:
$putBatch = WriteRequestBatch::factory($ddb_client);
$putBatch->add(new PutRequest($item, 'my_table'));
// ADD MORE...
// ...
// ...
$putBatch->flush();
Here is another example of using the WriteRequestBatch from the SDK's User Guide.
EDIT: One more complete example that works that I just tested, that shows the difference between versions prior to 2.7.0 and afterwards
use Aws\DynamoDb\DynamoDbClient;
use Aws\DynamoDb\Model\BatchRequest\WriteRequestBatch;
use Aws\DynamoDb\Model\BatchRequest\PutRequest;
use Aws\DynamoDb\Model\Item;
$client = DynamoDbClient::factory([/* ... */]);
$batch = WriteRequestBatch::factory($client);
for ($i = 1; $i <= 55; $i++) {
// FOR ANY SDK VERSION
// (NOTE: Does not support new M, L, BOOL, and NULL types)
$item = Item::fromArray(['id' => $i, 'data' => "foo{$i}"]);
// FOR SDK >= 2.7
$item = ['id' => ['N' => $i], 'data' => ['S' => "foo{$i}"]];
$batch->add(new PutRequest($item, 'my-table'));
}
$batch->flush();
Because you currently do not have any "try / catch" error handling around your code you are likely not getting good information on your error.
I placed try/catch blocks on your code and found that the table creates just fine but that the call to putItem fails for the following reason: Requested resource not found
When you create a table it is NOT immediately available. You have to pause until it becomes available. This paragraph of the AWS docs explains this nicely:
CreateTable is an asynchronous operation. Upon receiving a CreateTable request, DynamoDB immediately returns a response with a TableStatus of CREATING . After the table is created, DynamoDB sets the TableStatus to ACTIVE . You can perform read and write operations only on an ACTIVE table. You can use the DescribeTable API to check the table status.
Once you add the call to DescribeTable like it shows, you should be good.

Categories