如何使用MangoPay PHP SDK创建preAuthorized PayIn?

时间:2014-11-26 14:40:52

标签: php

我目前正在使用MangoPay api(使用PHP SDK)开展项目,而且我在PaymentDetails方面遇到了一些问题。下面的函数生成此密钥(当我在PayIn对象上调用MangoPay Create方法时):

payins_stdclass-direct_create

而不是:

payins_preauthorized-direct_create

我使用的功能:

<?php
private function createAuthorizationPayIn($authorization, $fees)
{       
     $payIn = new MangoPay\PayIn();

     $payIn->CreditedWalletId = $this->adminWalletId;        
     $payIn->AuthorId = $this->adminUserId;

     $payIn->PaymentType = "PREAUTHORIZED";
     $PayIn->PaymentDetails = new MangoPay\PayInPaymentDetailsPreAuthorized();
     $payIn->PaymentDetails->PreauthorizationId = $authorization->Id;

     $payIn->DebitedFunds = new MangoPay\Money();
     $payIn->DebitedFunds->Currency = $authorization->DebitedFunds->Currency;
     $payIn->DebitedFunds->Amount = $authorization->DebitedFunds->Amount;

     $payIn->CreditedFunds = new MangoPay\Money();
     $payIn->CreditedFunds->Currency = $authorization->DebitedFunds->Currency;
     $payIn->CreditedFunds->Amount = $authorization->DebitedFunds->Amount;

     $payIn->Fees = $fees;

     $payIn->ExecutionType = "DIRECT";
     $payIn->ExecutionDetails = new MangoPay\PayInExecutionDetailsDirect();
     $payIn->ExecutionDetails->SecureMode = "DEFAULT";
     $payIn->ExecutionDetails->SecureModeReturnURL = "https://website.com";

     $payIn = $this->mangoPayApi->PayIns->Create($payIn);

     $authorization->payinId = $payIn->Id;
     $authorization = $this->mangoPayApi->CardPreAuthorizations->Update($authorization);

     return $payIn;
}

如何创建正确的PaymentDetails对象以创建preAuthorized PayIn?

0 个答案:

没有答案