NinoSkopac

PP PHP SDK: Paying for item with a bank account doesn't work

Jun 16th, 2016
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 3.85 KB | None | 0 0
  1. public function testGetBankAccount() {
  2.     // create Item
  3.     $itemData = array(
  4.         "id"              => GUID(),
  5.         "name"            => 'Item #12893489',
  6.         "amount"          => 1000,
  7.         "payment_type"    => 2,
  8.         "buyer_id"        => "fdf58725-96bd-4bf8-b5e6-9b61be20662e",
  9.         "seller_id"       => "ec9bf096-c505-4bef-87f6-18822b9dbf2c",
  10.         "description"     => "This is item's description."
  11.     );
  12.    
  13.     $buyerBank = PromisePay::User()->getBankAccount(
  14.         $itemData['buyer_id']
  15.     );
  16.    
  17.     $sellerBank = PromisePay::User()->getBankAccount(
  18.         $itemData['seller_id']
  19.     );
  20.    
  21.     $item = PromisePay::Item()->create($itemData);
  22.    
  23.     // create authority
  24.     $directDebitAUthority = PromisePay::DirectDebitAuthority()->create(
  25.         array(
  26.             'account_id' => $buyerBank['id'],
  27.             'amount' => $itemData['amount']
  28.         )
  29.     );
  30.    
  31.     // request payment
  32.     $requestPayment = PromisePay::Item()->requestPayment(
  33.         $item['id']
  34.     );
  35.    
  36.     // acknowledge wire
  37.     $ackWire = PromisePay::Item()->acknowledgeWire($item['id']);
  38.    
  39.     // pay for item
  40.     $makePayment = PromisePay::Item()->makePayment(
  41.         $item['id'],
  42.         array(
  43.             'account_id' => $buyerBank['id']
  44.         )
  45.     );
  46.    
  47.     $wireDetails = PromisePay::Item()->getWireDetails($item['id']);
  48.     $this->assertNotNull($wireDetails); // this passes
  49.    
  50.     print_r($makePayment); // state is payment_pending, instead of completed (see below for full dump)
  51.    
  52.     $itemTransactions = PromisePay::Transaction()->getList(
  53.         array(
  54.             'limit' => 200,
  55.             'item_id' => $item['id']
  56.         )
  57.     );
  58.    
  59.     var_dump($itemTransactions); // yields NULL instead of array
  60. }
  61.  
  62. /*
  63. print_r($makePayment);
  64.  
  65. (
  66.     [id] => dbb29e6c-2125-4bb1-b0c5-243d04346e54
  67.     [name] => Item #12893489
  68.     [description] => This is item's description.
  69.     [created_at] => 2016-06-17T00:58:47.877Z
  70.     [updated_at] => 2016-06-17T00:58:53.310Z
  71.     [state] => payment_pending
  72.     [net_amount] => 1000
  73.     [refunded_amount] => 0
  74.     [released_amount] => 0
  75.     [buyer_fees] => 0
  76.     [seller_fees] => 0
  77.     [credit_card_fee] => 0
  78.     [paypal_fee] => 0
  79.     [seller_url] =>
  80.     [buyer_url] =>
  81.     [direct_debit_fee] => 0
  82.     [status] => 22150
  83.     [amount] => 1000
  84.     [payment_type_id] => 2
  85.     [due_date] =>
  86.     [pending_release_amount] => 0
  87.     [deposit_reference] => 100014014942525
  88.     [promisepay_fee] => 17
  89.     [total_outstanding] => 1000
  90.     [total_amount] => 1000
  91.     [currency] => AUD
  92.     [payment_method] => pending
  93.     [buyer_name] => Test Test
  94.     [buyer_email] => [email protected]
  95.     [buyer_country] => AUS
  96.     [seller_name] => test sdfdf edited Test
  97.     [seller_email] => [email protected]
  98.     [seller_country] => AUS
  99.     [payment_credit_card_enabled] => 1
  100.     [payment_direct_debit_enabled] => 1
  101.     [related] => Array
  102.         (
  103.             [buyers] => fdf58725-96bd-4bf8-b5e6-9b61be20662e
  104.             [sellers] => ec9bf096-c505-4bef-87f6-18822b9dbf2c
  105.         )
  106.  
  107.     [links] => Array
  108.         (
  109.             [self] => /items/dbb29e6c-2125-4bb1-b0c5-243d04346e54/make_payment?account_id=539818e1-23cc-4939-bcbc-b265cfdfd669
  110.             [buyers] => /items/dbb29e6c-2125-4bb1-b0c5-243d04346e54/buyers
  111.             [sellers] => /items/dbb29e6c-2125-4bb1-b0c5-243d04346e54/sellers
  112.             [status] => /items/dbb29e6c-2125-4bb1-b0c5-243d04346e54/status
  113.             [fees] => /items/dbb29e6c-2125-4bb1-b0c5-243d04346e54/fees
  114.             [transactions] => /items/dbb29e6c-2125-4bb1-b0c5-243d04346e54/transactions
  115.             [wire_details] => /items/dbb29e6c-2125-4bb1-b0c5-243d04346e54/wire_details
  116.             [bpay_details] => /items/dbb29e6c-2125-4bb1-b0c5-243d04346e54/bpay_details
  117.         )
  118.  
  119. )
  120. */
Add Comment
Please, Sign In to add comment